home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Tools / MUI / Developer / C / Examples / psi.c < prev    next >
C/C++ Source or Header  |  1996-08-20  |  89KB  |  2,862 lines

  1. /*
  2.  
  3. Public Screen Inspector Source Code
  4. -----------------------------------
  5.  
  6. This source acts as an example of good object-oriented MUI programming.
  7. Lots of important techniques are demonstrated:
  8.  
  9. - Sub Classes:
  10.   The complete application consists of several independant sub classes
  11.   which are connected to create a screen manager. This is one of the
  12.   *major* issues of good MUI programming. Don't put everything into
  13.   your main loop, use classes instead!
  14.  
  15. - Dynamic Object Creation:
  16.   Creating all the objects of an application at startup time is often
  17.   unnecessary and wastes time and memory. Instead, create the objects
  18.   only when you need them, add them dynamically to your application
  19.   and dispose them when you're done. Here, edit windows are created
  20.   on demand and color wheels only show up when needed.
  21.  
  22. - Multi Threading:
  23.   Sub classes and dynamic object generation make it easy to create
  24.   multi-threaded programs. With the screen manager, the user will be
  25.   able to edit as many screens as he wants at once.
  26.  
  27. - Drag&Drop:
  28.   Drag&Drop possibilities are important for a good GUI and are implemented
  29.   with a few lines of code. The color panel in this program is a good
  30.   example.
  31.  
  32.  
  33. Let's describe the process of creating a nice MUI application with this
  34. screen manager example. Maybe the following explanation sounds a bit
  35. crazy at first, but you should read it completely anyway to get an idea
  36. of how object-oriented programming is supposed to work.
  37.  
  38. At startup time, the screen manager opens a window which offers
  39. possibilities to edit a public screen list and to Save/Use/Cancel the
  40. work. This window is the main window of the program and since we want to
  41. be nice object-oriented, we will of course create a MainWindow class as
  42. subclass of window class for our window.
  43.  
  44. The MainWindow class itself features a screen list with edit buttons
  45. and the well known Save/Use/Cancel buttons. Of course, the screen list
  46. with edit buttons is not included directly but instead encapsulated in
  47. another sub class called the ScreenPanel class.
  48.  
  49. ScreenPanel class is a sub class of group class and includes a listview
  50. with all defined public screens (which is in fact created by a sub class
  51. of list class, the ScreenList class) and some New/Delete/Edit buttons
  52. below the listview. It implements methods to open and close edit windows
  53. for each entry of the listview and calls these methodes itself whenever
  54. the user presses an appropriate button. Guess what... when a list entry
  55. needs to be edited, ScreenPanel class simply creates a new instance of
  56. the EditWindow class.
  57.  
  58. As a subclass of window class, EditWindow opens a window which lets the
  59. user edit the data of a public screen. Of course it doesn't handle this
  60. editing itself, an EditWindow itself only consists of an EditPanel sub
  61. class and two obvious OK and Cancel buttons.
  62.  
  63. EditPanel sub class is a subclass of group class and offers three
  64. different pages to change the public screen data. This class is
  65. somewhat *major* since the main action of the program, the editing
  66. of public screen data, takes place here. Of course, the EditPanel
  67. class doesn't do all the editing work itself. Instead, it relies
  68. on further sub classes, e.g. a DispIDlist which creates a list
  69. of of available DisplayIDs or a DispIDinfo list which shows
  70. information on a specific display ID.
  71.  
  72. Ok... that's basically the description of the object oriented screen
  73. manager. Let's repeat the sub class structure of this application
  74. again in a little diagram. Every class consists of the sub classes
  75. included in the first level of braces below its name.
  76.  
  77. ApplicationClass
  78. {
  79.     MainWindow
  80.     {
  81.         ScreenPanel
  82.         {
  83.             ScreenList
  84.             {
  85.                 EditWindow
  86.                 {
  87.                     EditPanel
  88.                     {
  89.                         DispIDlist
  90.                         DispIDinfo
  91.                     }
  92.                     OK/Cancel
  93.                 }
  94.             }
  95.             New/Delete/Edit
  96.         }
  97.         Save/Use/Cancel
  98.     }
  99. }
  100.  
  101. Maybe you think that this sub classing is a bit overpowered or
  102. unnecessary or ridicolous, you could do everything just fine with one
  103. big Main-Loop which contains everything you need. Let me tell you one
  104. thing: You can never have enough sub classes in an application! :-)
  105.  
  106. The smaller your classes are, the lesser complex your complete project
  107. will be. When working on "higher levels" of your program, e.g. when
  108. adding more functionality to the ScreenPanel or to the MainWindow, you
  109. don't have to think about side effects and stuff on the lower levels. As
  110. long as each class has it's well defined set of attributes and methods,
  111. everything will continue to work like a charm.
  112.  
  113. On the other side, when fixing bugs or e.g. implementing new features
  114. like Drag&Drop for a "low-level" class like the DispIDlist, you have to
  115. deal with just a few lines of code, not with a big bunch of lines from a
  116. complete application.
  117.  
  118. To come to the point... when building a new application, you should
  119. first think of what different parts your program consists of and how you
  120. could divide your work in big sub classes. Then, take the big classes
  121. and split each of them into smaller classes, take the smaller classes
  122. and split them even more. Split as long as you are unable to split
  123. anymore! If you splitted nicely, you will have lots of classes which all
  124. perform some well-defined actions and are all very easy to implement.
  125.  
  126. A few more tips...
  127.  
  128. - Don't use ReturnIDs!
  129.     I feel very sorry that I implemented this rubbish in MUI. ReturnIDs are
  130.     completely against object-orientation and break the nice class structure
  131.     that every MUI application should have. The ideal input loop of every
  132.     application looks like this:
  133.  
  134.     {
  135.         ULONG sigs = 0;
  136.  
  137.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  138.         {
  139.             if (sigs)
  140.             {
  141.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  142.                 if (sigs & SIGBREAKF_CTRL_C) break;
  143.             }
  144.         }
  145.     }
  146.  
  147.     That's it. If you're input loop looks different, i.e. if you use the
  148.     return value of the input method for more than the QUIT check, you're
  149.     program is not as object-oriented as it could be. Feel ashamed! :-)
  150. */
  151.  
  152. #include "psi.h"
  153.  
  154.  
  155. #define BETWEEN(a,x,b) ((x)>=(a) && (x)<=(b))
  156.  
  157.  
  158. /****************************************************************************/
  159. /* Private Functions of muiscreen.library                                   */
  160. /****************************************************************************/
  161.  
  162. /*
  163. ** NOTE: Never use one of these in your own programs. I guarantee to change
  164. **       the offsets with every new MUI release.
  165. */
  166.  
  167. struct MUI_PubScreenDesc *MUIS_AllocPubScreenDesc(struct MUI_PubScreenDesc *src);
  168. VOID                      MUIS_FreePubScreenDesc(struct MUI_PubScreenDesc *psd);
  169. char *                    MUIS_OpenPubScreen(struct MUI_PubScreenDesc *desc);
  170. BOOL                      MUIS_ClosePubScreen(char *name);
  171. APTR                      MUIS_OpenPubFile(char *name,ULONG mode);
  172. VOID                      MUIS_ClosePubFile(APTR pf);
  173. struct MUI_PubScreenDesc *MUIS_ReadPubFile(APTR pf);
  174. BOOL                      MUIS_WritePubFile(APTR pf,struct MUI_PubScreenDesc *desc);
  175. VOID                      MUIS_AddInfoClient(struct MUIS_InfoClient *sic);
  176. VOID                      MUIS_RemInfoClient(struct MUIS_InfoClient *sic);
  177.  
  178. #pragma libcall MUIScreenBase MUIS_AllocPubScreenDesc 1e 801
  179. #pragma libcall MUIScreenBase MUIS_FreePubScreenDesc 24 801
  180. #pragma libcall MUIScreenBase MUIS_OpenPubFile 2a 0802
  181. #pragma libcall MUIScreenBase MUIS_ClosePubFile 30 801
  182. #pragma libcall MUIScreenBase MUIS_ReadPubFile 36 801
  183. #pragma libcall MUIScreenBase MUIS_WritePubFile 3c 9802
  184. #pragma libcall MUIScreenBase MUIS_OpenPubScreen 42 801
  185. #pragma libcall MUIScreenBase MUIS_ClosePubScreen 48 801
  186. #pragma libcall MUIScreenBase MUIS_AddInfoClient 4e 801
  187. #pragma libcall MUIScreenBase MUIS_RemInfoClient 54 801
  188.  
  189.  
  190.  
  191. /****************************************************************************/
  192. /* Global Vars                                                              */
  193. /****************************************************************************/
  194.  
  195. LONG __stack = 8192;
  196.  
  197. struct Library *MUIScreenBase;
  198. struct Library *MUIMasterBase;
  199. struct Library *GfxBase      ;
  200. struct Library *IntuitionBase;
  201. struct Library *LocaleBase   ;
  202. struct Library *AslBase      ;
  203. struct Library *UtilityBase  ;
  204.  
  205. extern struct Library *DOSBase;
  206.  
  207. struct Catalog *Catalog;
  208.  
  209. struct MUI_CustomClass *CL_EditWindow  ;
  210. struct MUI_CustomClass *CL_EditPanel   ;
  211. struct MUI_CustomClass *CL_SysPenField ;
  212. struct MUI_CustomClass *CL_DispIDlist  ;
  213. struct MUI_CustomClass *CL_DispIDinfo  ;
  214. struct MUI_CustomClass *CL_ScreenList  ;
  215. struct MUI_CustomClass *CL_ScreenPanel ;
  216. struct MUI_CustomClass *CL_MainWindow  ;
  217.  
  218. #define TG CHECKIT|MENUTOGGLE
  219.  
  220. enum { MEN_OPEN=1,MEN_APPEND,MEN_SAVEAS,MEN_ABOUT,MEN_QUIT,MEN_LASTSAVED,MEN_RESTORE,MEN_MUI };
  221. struct NewMenu MainMenu[] =
  222. {
  223.     { NM_TITLE, (STRPTR)MSG_MENU_PROJECT          , 0 ,0,0,(APTR)0             },
  224.     { NM_ITEM , (STRPTR)MSG_MENU_PROJECT_OPEN     ,"O",0,0,(APTR)MEN_OPEN      },
  225.     { NM_ITEM , (STRPTR)MSG_MENU_PROJECT_APPEND   ,"P",0,0,(APTR)MEN_APPEND    },
  226.     { NM_ITEM , (STRPTR)MSG_MENU_PROJECT_SAVEAS   ,"A",0,0,(APTR)MEN_SAVEAS    },
  227.     { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  228.     { NM_ITEM , (STRPTR)MSG_MENU_PROJECT_ABOUT    ,"?",0,0,(APTR)MEN_ABOUT     },
  229.     { NM_ITEM , (STRPTR)NM_BARLABEL               , 0 ,0,0,(APTR)0             },
  230.     { NM_ITEM , (STRPTR)MSG_MENU_PROJECT_QUIT     ,"Q",0,0,(APTR)MEN_QUIT      },
  231.  
  232.     { NM_TITLE, (STRPTR)MSG_MENU_EDIT             , 0 ,0,0,(APTR)0             },
  233.     { NM_ITEM , (STRPTR)MSG_MENU_EDIT_LASTSAVED   ,"L",0,0,(APTR)MEN_LASTSAVED },
  234.     { NM_ITEM , (STRPTR)MSG_MENU_EDIT_RESTORE     ,"R",0,0,(APTR)MEN_RESTORE   },
  235.  
  236.     { NM_TITLE, (STRPTR)MSG_MENU_SETTINGS         , 0 ,0,0,(APTR)0             },
  237.     { NM_ITEM , (STRPTR)MSG_MENU_SETTINGS_MUI     , 0 ,0,0,(APTR)MEN_MUI       },
  238.  
  239.     { NM_END,NULL,0,0,0,(APTR)0 },
  240. };
  241.  
  242. struct NewMenu PaletteMenu[] =
  243. {
  244.     { NM_TITLE, (STRPTR)MSG_PALPRES_TITLE, 0 , 0,0,(APTR)0   },
  245.     { NM_ITEM , (STRPTR)MSG_PALPRES_CLONEWB  , 0,0,0,(APTR)10},
  246.     { NM_ITEM , (STRPTR)NM_BARLABEL          , 0,0,0,(APTR)0 },
  247.     { NM_ITEM , (STRPTR)MSG_PALPRES_MAGICWB  , 0,0,0,(APTR)9 },
  248.     { NM_ITEM , (STRPTR)NM_BARLABEL          , 0,0,0,(APTR)0 },
  249.     { NM_ITEM , (STRPTR)MSG_PALPRES_STANDARD , 0,0,0,(APTR)0 },
  250.     { NM_ITEM , (STRPTR)MSG_PALPRES_TINT     , 0,0,0,(APTR)1 },
  251.     { NM_ITEM , (STRPTR)MSG_PALPRES_PHARAO   , 0,0,0,(APTR)2 },
  252.     { NM_ITEM , (STRPTR)MSG_PALPRES_SUNSET   , 0,0,0,(APTR)3 },
  253.     { NM_ITEM , (STRPTR)MSG_PALPRES_OCEAN    , 0,0,0,(APTR)4 },
  254.     { NM_ITEM , (STRPTR)MSG_PALPRES_STEEL    , 0,0,0,(APTR)5 },
  255.     { NM_ITEM , (STRPTR)MSG_PALPRES_CHOCOLATE, 0,0,0,(APTR)6 },
  256.     { NM_ITEM , (STRPTR)MSG_PALPRES_PEWTER   , 0,0,0,(APTR)7 },
  257.     { NM_ITEM , (STRPTR)MSG_PALPRES_WINE     , 0,0,0,(APTR)8 },
  258.  
  259.     { NM_END,NULL,0,0,0,(APTR)0 },
  260. };
  261.  
  262. char *CYA_EditPages[] =
  263. {
  264.     (char *)MSG_EDITPAGE_ATTRIBUTES,
  265.     (char *)MSG_EDITPAGE_DISPLAY,
  266.     (char *)MSG_EDITPAGE_COLORS,
  267.     NULL
  268. };
  269.  
  270. char *CYA_Overscan[] =
  271. {
  272.     (char *)MSG_OVERSCAN_TEXT,
  273.     (char *)MSG_OVERSCAN_GRAPHICS,
  274.     (char *)MSG_OVERSCAN_EXTREME,
  275.     (char *)MSG_OVERSCAN_MAXIMUM,
  276.     NULL
  277. };
  278.  
  279.  
  280. /****************************************************************************/
  281. /* Locale Stuff                                                             */
  282. /****************************************************************************/
  283.  
  284. char *GetStr(int num)
  285. {
  286.     struct CatCompArrayType *cca = (struct CatCompArrayType *)CatCompArray;
  287.     while (cca->cca_ID != num) cca++;
  288.     if (LocaleBase) return(GetCatalogStr(Catalog,num,cca->cca_Str));
  289.     return((char *)cca->cca_Str);
  290. }
  291.  
  292. VOID LocalizeStringArray(char **array)
  293. {
  294.     char **x;
  295.     for (x=array;*x;x++)
  296.         *x = GetStr((int)*x);
  297. }
  298.  
  299. VOID LocalizeNewMenu(struct NewMenu *nm)
  300. {
  301.     for (;nm->nm_Type!=NM_END;nm++)
  302.         if (nm->nm_Label != NM_BARLABEL)
  303.             nm->nm_Label = GetStr((int)nm->nm_Label);
  304. }
  305.  
  306. VOID InitLocale(VOID)
  307. {
  308.     if (LocaleBase = OpenLibrary("locale.library",38))
  309.         Catalog = OpenCatalog(NULL,"PSI.catalog",OC_Version,MUIMASTER_VLATEST,TAG_DONE);
  310.  
  311.     LocalizeNewMenu(MainMenu);
  312.     LocalizeNewMenu(PaletteMenu);
  313.     /*LocalizeNewMenu(EditMenu);*/
  314.     LocalizeStringArray(CYA_Overscan);
  315.     LocalizeStringArray(CYA_EditPages);
  316. }
  317.  
  318. VOID ExitLocale(VOID)
  319. {
  320.     if (Catalog) { CloseCatalog(Catalog); Catalog=NULL; }
  321.     if (LocaleBase) CloseLibrary(LocaleBase); { LocaleBase=NULL; }
  322. }
  323.  
  324.  
  325.  
  326. /****************************************************************************/
  327. /* Misc Help Functions                                                      */
  328. /****************************************************************************/
  329.  
  330. LONG xget(Object *obj,ULONG attribute)
  331. {
  332.     LONG x;
  333.     get(obj,attribute,&x);
  334.     return(x);
  335. }
  336.  
  337. char *getstr(Object *obj)
  338. {
  339.     return((char *)xget(obj,MUIA_String_Contents));
  340. }
  341.  
  342. BOOL getbool(Object *obj)
  343. {
  344.     return((BOOL)xget(obj,MUIA_Selected));
  345. }
  346.  
  347. VOID setstr(APTR str,LONG num)
  348. {
  349.     DoMethod(str,MUIM_SetAsString,MUIA_String_Contents,"%ld",num);
  350. }
  351.  
  352. VOID settxt(APTR str,LONG num)
  353. {
  354.     DoMethod(str,MUIM_SetAsString,MUIA_Text_Contents,"%ld",num);
  355. }
  356.  
  357. ULONG __stdargs DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
  358. {
  359.     return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
  360. }
  361.  
  362. Object *MakeCheck(int num)
  363. {
  364.     Object *obj = MUI_MakeObject(MUIO_Checkmark,GetStr(num));
  365.     if (obj) set(obj,MUIA_CycleChain,1);
  366.     return(obj);
  367. }
  368.  
  369. Object *MakeButton(int num)
  370. {
  371.     Object *obj = MUI_MakeObject(MUIO_Button,GetStr(num));
  372.     if (obj) set(obj,MUIA_CycleChain,1);
  373.     return(obj);
  374. }
  375.  
  376. /*
  377. Object *MakeBackground(int num)
  378. {
  379.     Object *obj;
  380.  
  381.     obj = MUI_NewObject(MUIC_Popimage,
  382.         MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Background,
  383.         MUIA_Window_Title, "Adjust Screen Background",
  384.         MUIA_CycleChain, 1,
  385.         TAG_DONE);
  386.  
  387.     return(obj);
  388. }
  389. */
  390.  
  391. Object *MakeString(int maxlen,int num)
  392. {
  393.     Object *obj = MUI_MakeObject(MUIO_String,GetStr(num),maxlen);
  394.  
  395.     if (obj)
  396.     {
  397.         SetAttrs(obj,
  398.             MUIA_CycleChain,1,
  399.             MUIA_String_AdvanceOnCR,TRUE,
  400.             TAG_DONE);
  401.     }
  402.  
  403.     return(obj);
  404. }
  405.  
  406. Object *MakeCycle(char **array,int num)
  407. {
  408.     Object *obj = MUI_MakeObject(MUIO_Cycle ,GetStr(num),array);
  409.     if (obj) set(obj,MUIA_CycleChain,1);
  410.     return(obj);
  411. }
  412.  
  413. Object *MakeSlider(int min,int max,int num)
  414. {
  415.     Object *obj = MUI_MakeObject(MUIO_Slider,GetStr(num),min,max);
  416.     if (obj) set(obj,MUIA_CycleChain,1);
  417.     return(obj);
  418. }
  419.  
  420.  
  421. static Object *MakeCLabel(int num) { return(MUI_MakeObject(MUIO_Label,GetStr(num),MUIO_Label_Centered)); }
  422.  
  423. Object *MakeLabel    (int num)  { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),0)); }
  424. Object *MakeLabel1   (int num)  { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),MUIO_Label_SingleFrame)); }
  425. Object *MakeLabel2   (int num)  { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),MUIO_Label_DoubleFrame)); }
  426. Object *MakeLLabel   (int num)  { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),MUIO_Label_LeftAligned)); }
  427. Object *MakeLLabel1  (int num)  { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),MUIO_Label_LeftAligned|MUIO_Label_SingleFrame)); }
  428. Object *MakeFreeLabel(int num)  { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),MUIO_Label_FreeVert)); }
  429. Object *MakeFreeLLabel(int num) { return(MUI_MakeObject(MUIO_Label    ,GetStr(num),MUIO_Label_FreeVert|MUIO_Label_LeftAligned)); }
  430.  
  431. BOOL TestPubScreen(char *name)
  432. {
  433.     struct List *pslist;
  434.     struct PubScreenNode *psn,*succ;
  435.     BOOL res = FALSE;
  436.     pslist = LockPubScreenList();
  437.     ForEntries(pslist,psn,succ)
  438.     {
  439.         if (!stricmp(psn->psn_Node.ln_Name,name))
  440.         {
  441.             res = TRUE;
  442.             break;
  443.         }
  444.     }
  445.     UnlockPubScreenList();
  446.     return(res);
  447. }
  448.  
  449.  
  450. /****************************************************************************/
  451. /* DisplayIDinfo class                                                      */
  452. /****************************************************************************/
  453.  
  454. struct DispIDinfo_Data
  455. {
  456.     Object *TX_Visible[2];
  457.     Object *TX_Minimum[2];
  458.     Object *TX_Maximum[2];
  459.     Object *TX_BitsPerGun;
  460.     Object *TX_NumColors;
  461.     Object *TX_ScanRate;
  462.     Object *TX_ScanLine;
  463. };
  464.  
  465. Object *MakeMoni(LONG w,LONG h,LONG d,const UBYTE *body,const ULONG *colors)
  466. {
  467.     Object *obj = BodychunkObject,
  468.         MUIA_FixWidth             , w,
  469.         MUIA_FixHeight            , h,
  470.         MUIA_Bitmap_Width         , w,
  471.         MUIA_Bitmap_Height        , h,
  472.         MUIA_Bodychunk_Depth      , d,
  473.         MUIA_Bodychunk_Body       , (UBYTE *)body,
  474.         MUIA_Bodychunk_Compression, PSI_COLORS_COMPRESSION,
  475.         MUIA_Bodychunk_Masking    , PSI_COLORS_MASKING,
  476.         MUIA_Bitmap_SourceColors  , (ULONG *)colors,
  477.         MUIA_Bitmap_Transparent   , 0,
  478.         End;
  479.     return(obj);
  480. }
  481.  
  482. Object *MakeSize(void)
  483. {
  484.     Object *obj = TextObject,
  485.         MUIA_Text_Contents, "0",
  486.         MUIA_Text_PreParse, "\33r",
  487.         MUIA_FixWidthTxt, "00000",
  488.         End;
  489.     return(obj);
  490. }
  491.  
  492. ULONG DispIDinfo_New(struct IClass *cl,Object *obj,struct opSet *msg)
  493. {
  494.     Object *TX_Visible[2];
  495.     Object *TX_Minimum[2];
  496.     Object *TX_Maximum[2];
  497.     Object *TX_BitsPerGun;
  498.     Object *TX_NumColors;
  499.     Object *TX_ScanRate;
  500.     Object *TX_ScanLine;
  501.     Object *g1,*g2,*g3;
  502.  
  503.     obj = (Object *)DoSuperNew(cl,obj,
  504.         MUIA_Group_Columns, 2,
  505.         Child, g1 = MakeMoni(PSI_SIZES_WIDTH,PSI_SIZES_HEIGHT,PSI_SIZES_DEPTH,psi_sizes_body,psi_sizes_colors),
  506.         Child, ColGroup(4), MUIA_Group_VertSpacing, 0, MUIA_Group_HorizSpacing, 4,
  507.             Child, MakeLabel(MSG_LABEL_VISIBLE), Child, TX_Visible[0]=MakeSize(), Child, Label("x"), Child, TX_Visible[1]=MakeSize(),
  508.             Child, MakeLabel(MSG_LABEL_MINIMUM), Child, TX_Minimum[0]=MakeSize(), Child, Label("x"), Child, TX_Minimum[1]=MakeSize(),
  509.             Child, MakeLabel(MSG_LABEL_MAXIMUM), Child, TX_Maximum[0]=MakeSize(), Child, Label("x"), Child, TX_Maximum[1]=MakeSize(),
  510.             End,
  511.         Child, g2 = MakeMoni(PSI_COLORS_WIDTH,PSI_COLORS_HEIGHT,PSI_COLORS_DEPTH,psi_colors_body,psi_sizes_colors),
  512.         Child, ColGroup(2), MUIA_Group_VertSpacing, 0, MUIA_Group_HorizSpacing, 4,
  513.             Child, MakeLabel(MSG_LABEL_BITSPERGUN), Child, TX_BitsPerGun = TextObject, End,
  514.             Child, MakeLabel(MSG_LABEL_MAXIMUM   ), Child, TX_NumColors  = TextObject, End,
  515.             End,
  516.         Child, g3 = MakeMoni(PSI_FREQS_WIDTH,PSI_FREQS_HEIGHT,PSI_FREQS_DEPTH,psi_freqs_body,psi_sizes_colors),
  517.         Child, ColGroup(2), MUIA_Group_VertSpacing, 0, MUIA_Group_HorizSpacing, 4,
  518.             Child, MakeLabel(MSG_LABEL_SCANRATE), Child, TX_ScanRate = TextObject, End,
  519.             Child, MakeLabel(MSG_LABEL_SCANLINE), Child, TX_ScanLine = TextObject, End,
  520.             End,
  521.         TAG_MORE,msg->ops_AttrList);
  522.  
  523.     if (obj)
  524.     {
  525.         struct DispIDinfo_Data *data = INST_DATA(cl,obj);
  526.  
  527. /*
  528.         set(g1,MUIA_VertDisappear,3);
  529.         set(g2,MUIA_VertDisappear,2);
  530.         set(g3,MUIA_VertDisappear,1);
  531. */
  532.  
  533.         data->TX_Visible[0] = TX_Visible[0];
  534.         data->TX_Visible[1] = TX_Visible[1];
  535.         data->TX_Minimum[0] = TX_Minimum[0];
  536.         data->TX_Minimum[1] = TX_Minimum[1];
  537.         data->TX_Maximum[0] = TX_Maximum[0];
  538.         data->TX_Maximum[1] = TX_Maximum[1];
  539.         data->TX_BitsPerGun = TX_BitsPerGun;
  540.         data->TX_NumColors  = TX_NumColors;
  541.         data->TX_ScanRate   = TX_ScanRate;
  542.         data->TX_ScanLine   = TX_ScanLine;
  543.  
  544.         return((ULONG)obj);
  545.     }
  546.  
  547.     return(0);
  548. }
  549.  
  550. ULONG DispIDinfo_Set(struct IClass *cl,Object *obj,struct opSet *msg)
  551. {
  552.     #define offset(a,b) (((ULONG)b)-(((ULONG)a)))
  553.     struct DispIDinfo_Data *data = INST_DATA(cl,obj);
  554.     struct TagItem *tag;
  555.  
  556.     if (tag = FindTagItem(MUIA_DispIDinfo_ID,msg->ops_AttrList))
  557.     {
  558.         struct DisplayInfo   dis;
  559.         struct DimensionInfo dim;
  560.         struct MonitorInfo   mon;
  561.         int dislen;
  562.         int dimlen;
  563.         int monlen;
  564.  
  565.         set(data->TX_Visible[0],MUIA_String_Contents,"");
  566.         set(data->TX_Visible[1],MUIA_String_Contents,"");
  567.         set(data->TX_Minimum[0],MUIA_String_Contents,"");
  568.         set(data->TX_Minimum[1],MUIA_String_Contents,"");
  569.         set(data->TX_Maximum[0],MUIA_String_Contents,"");
  570.         set(data->TX_Maximum[1],MUIA_String_Contents,"");
  571.         set(data->TX_BitsPerGun,MUIA_String_Contents,"");
  572.         set(data->TX_NumColors ,MUIA_String_Contents,"");
  573.         set(data->TX_ScanRate  ,MUIA_String_Contents,"");
  574.         set(data->TX_ScanLine  ,MUIA_String_Contents,"");
  575.  
  576.         dislen = GetDisplayInfoData(0,(char *)&dis,sizeof(struct DisplayInfo  ),DTAG_DISP,tag->ti_Data);
  577.         dimlen = GetDisplayInfoData(0,(char *)&dim,sizeof(struct DimensionInfo),DTAG_DIMS,tag->ti_Data);
  578.         monlen = GetDisplayInfoData(0,(char *)&mon,sizeof(struct MonitorInfo  ),DTAG_MNTR,tag->ti_Data);
  579.  
  580.         if (dimlen>offset(&dim,&dim.MaxOScan))
  581.         {
  582.             settxt(data->TX_Visible[0],RectangleWidth (dim.MaxOScan));
  583.             settxt(data->TX_Visible[1],RectangleHeight(dim.MaxOScan));
  584.             settxt(data->TX_Minimum[0],dim.MinRasterWidth );
  585.             settxt(data->TX_Minimum[1],dim.MinRasterHeight);
  586.             settxt(data->TX_Maximum[0],dim.MaxRasterWidth );
  587.             settxt(data->TX_Maximum[1],dim.MaxRasterHeight);
  588.             settxt(data->TX_NumColors,1<<dim.MaxDepth);
  589.         }
  590.  
  591.         if (dislen>offset(&dis,&dis.BlueBits))
  592.         {
  593.             DoMethod(data->TX_BitsPerGun,MUIM_SetAsString,MUIA_Text_Contents,"%ld x %ld x %ld",dis.RedBits,dis.GreenBits,dis.BlueBits);
  594.         }
  595.  
  596.         if (monlen>offset(&mon,&mon.TotalColorClocks))
  597.         {
  598.             if (mon.TotalRows)
  599.             {
  600.                 ULONG vfreqint=1000000000L/((ULONG)mon.TotalColorClocks*280*mon.TotalRows/1000)+5;
  601.                 DoMethod(data->TX_ScanRate,MUIM_SetAsString,MUIA_Text_Contents,"%ld.%02ld Hz",vfreqint/1000,(vfreqint-(vfreqint/1000)*1000)/10);
  602.             }
  603.             if (mon.TotalColorClocks)
  604.             {
  605.                 ULONG hfreq=1000000000L/((ULONG)mon.TotalColorClocks*280)+5;
  606.                 ULONG hfreqint=hfreq/1000;
  607.                 DoMethod(data->TX_ScanLine,MUIM_SetAsString,MUIA_Text_Contents,"%ld.%02ld kHz",hfreqint,(hfreq-hfreqint*1000)/10);
  608.             }
  609.         }
  610.     }
  611.  
  612.     return(DoSuperMethodA(cl,obj,msg));
  613. }
  614.  
  615. SAVEDS ASM ULONG DispIDinfo_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  616. {
  617.     switch (msg->MethodID)
  618.     {
  619.         case OM_NEW: return(DispIDinfo_New(cl,obj,(APTR)msg));
  620.         case OM_SET: return(DispIDinfo_Set(cl,obj,(APTR)msg));
  621.     }
  622.     return(DoSuperMethodA(cl,obj,msg));
  623. }
  624.  
  625.  
  626.  
  627. /****************************************************************************/
  628. /* DisplayIDlist class                                                      */
  629. /****************************************************************************/
  630.  
  631. struct DispIDlist_Data
  632. {
  633.     ULONG CurrentID;
  634.     struct Hook ConstructHook;
  635.     struct Hook DisplayHook;
  636. };
  637.  
  638. SAVEDS ASM LONG DispIDlist_DisplayFunc(REG(a2) char **array,REG(a1) struct NameInfo *ni)
  639. {
  640.     *array = ni->Name;
  641.     return(0);
  642. }
  643.  
  644. SAVEDS ASM LONG DispIDlist_CompareFunc(REG(a1) struct NameInfo *n1,REG(a2) struct NameInfo *n2)
  645. {
  646.     return(stricmp(n1->Name,n2->Name));
  647. }
  648.  
  649. SAVEDS ASM VOID DispIDlist_DestructFunc(REG(a1) struct NameInfo *ni)
  650. {
  651.     FreeVec(ni);
  652. }
  653.  
  654. SAVEDS ASM APTR DispIDlist_ConstructFunc(REG(a1) ULONG modeid)
  655. {
  656.     APTR handle;
  657.     struct NameInfo NameInfo;
  658.     struct DisplayInfo DisplayInfo;
  659.     struct DimensionInfo DimensionInfo;
  660.     struct NameInfo *ni;
  661.  
  662.     if ((modeid & MONITOR_ID_MASK)==DEFAULT_MONITOR_ID) return(NULL);
  663.     if (!(handle = FindDisplayInfo(modeid))) return(NULL);
  664.     if (!GetDisplayInfoData(handle,(char *)&NameInfo     ,sizeof(struct NameInfo     ),DTAG_NAME,0)) return(NULL);
  665.     if (!GetDisplayInfoData(handle,(char *)&DisplayInfo  ,sizeof(struct DisplayInfo  ),DTAG_DISP,0)) return(NULL);
  666.     if (!GetDisplayInfoData(handle,(char *)&DimensionInfo,sizeof(struct DimensionInfo),DTAG_DIMS,0)) return(NULL);
  667.     if (!(DisplayInfo.PropertyFlags & DIPF_IS_WB)) return(NULL);
  668.     if (DisplayInfo.NotAvailable) return(NULL);
  669.     if (!(ni = AllocVec(sizeof(struct NameInfo),MEMF_ANY))) return(NULL);
  670.  
  671.     *ni = NameInfo;
  672.     return(ni);
  673. }
  674.  
  675. ULONG DispIDlist_New(struct IClass *cl,Object *obj,Msg msg)
  676. {
  677.     static const struct Hook ConstructHook = { { NULL,NULL },(VOID *)DispIDlist_ConstructFunc,NULL,NULL };
  678.     static const struct Hook DestructHook  = { { NULL,NULL },(VOID *)DispIDlist_DestructFunc ,NULL,NULL };
  679.     static const struct Hook CompareHook   = { { NULL,NULL },(VOID *)DispIDlist_CompareFunc  ,NULL,NULL };
  680.     static const struct Hook DisplayHook   = { { NULL,NULL },(VOID *)DispIDlist_DisplayFunc  ,NULL,NULL };
  681.     LONG id = INVALID_ID;
  682.  
  683.     if (!(obj=(Object *)DoSuperMethodA(cl,obj,msg)))
  684.         return(0);
  685.  
  686.     SetSuperAttrs(cl,obj,
  687.         MUIA_List_ConstructHook, &ConstructHook,
  688.         MUIA_List_DestructHook , &DestructHook,
  689.         MUIA_List_CompareHook  , &CompareHook,
  690.         MUIA_List_DisplayHook  , &DisplayHook,
  691.         MUIA_List_AutoVisible  , TRUE,
  692.         TAG_DONE);
  693.  
  694.     while ((id=NextDisplayInfo(id))!=INVALID_ID)
  695.         DoMethod(obj,MUIM_List_InsertSingle,id,MUIV_List_Insert_Bottom);
  696.  
  697.     DoMethod(obj,MUIM_List_Sort);
  698.  
  699.     DoMethod(obj,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,obj,1,MUIM_DispIDlist_Change);
  700.  
  701.     return((ULONG)obj);
  702. }
  703.  
  704. ULONG DispIDlist_Set(struct IClass *cl,Object *obj,struct opSet *msg)
  705. {
  706.     struct DispIDlist_Data *data = INST_DATA(cl,obj);
  707.     struct TagItem *tag,*quiet;
  708.  
  709.     quiet = FindTagItem(MUIA_DispIDlist_Quiet,msg->ops_AttrList);
  710.  
  711.     if (tag = FindTagItem(MUIA_DispIDlist_CurrentID,msg->ops_AttrList))
  712.     {
  713.         data->CurrentID = tag->ti_Data;
  714.  
  715.         if (!quiet)
  716.         {
  717.             int i;
  718.             struct NameInfo *ni;
  719.             ULONG mask = 0;
  720.  
  721.             for (;;)
  722.             {
  723.                 for (i=0;;i++)
  724.                 {
  725.                     DoMethod(obj,MUIM_List_GetEntry,i,&ni);
  726.                     if (!ni) break;
  727.                     if ((ni->Header.DisplayID & ~mask)==(data->CurrentID & ~mask)) { mask = MONITOR_ID_MASK; break; }
  728.                 }
  729.                 if (!ni) break;
  730.                 if (mask==MONITOR_ID_MASK) break;
  731.                 mask = MONITOR_ID_MASK;
  732.             }
  733.  
  734.             if (ni)
  735.                 set(obj,MUIA_List_Active,i);
  736.             else
  737.                 set(obj,MUIA_List_Active,MUIV_List_Active_Off);
  738.         }
  739.     }
  740.     return(DoSuperMethodA(cl,obj,msg));
  741. }
  742.  
  743. ULONG DispIDlist_Get(struct IClass *cl,Object *obj,struct opGet *msg)
  744. {
  745.     struct DispIDlist_Data *data = INST_DATA(cl,obj);
  746.  
  747.     switch (msg->opg_AttrID)
  748.     {
  749.         case MUIA_DispIDlist_CurrentID:
  750.             *(msg->opg_Storage) = data->CurrentID;
  751.             return(TRUE);
  752.     }
  753.  
  754.     return(DoSuperMethodA(cl,obj,msg));
  755. }
  756.  
  757. ULONG DispIDlist_Change(struct IClass *cl,Object *obj,Msg msg)
  758. {
  759.     struct NameInfo *ni;
  760.     DoMethod(obj,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&ni);
  761.     SetAttrs(obj,
  762.         MUIA_DispIDlist_Quiet,TRUE,
  763.         MUIA_DispIDlist_CurrentID,ni ? ni->Header.DisplayID : INVALID_ID,
  764.         TAG_DONE);
  765.     return(0);
  766. }
  767.  
  768. SAVEDS ASM ULONG DispIDlist_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  769. {
  770.     switch (msg->MethodID)
  771.     {
  772.         case OM_NEW: return(DispIDlist_New(cl,obj,(APTR)msg));
  773.         case OM_SET: return(DispIDlist_Set(cl,obj,(APTR)msg));
  774.         case OM_GET: return(DispIDlist_Get(cl,obj,(APTR)msg));
  775.         case MUIM_DispIDlist_Change: return(DispIDlist_Change(cl,obj,(APTR)msg));
  776.     }
  777.     return(DoSuperMethodA(cl,obj,msg));
  778. }
  779.  
  780.  
  781.  
  782. /****************************************************************************/
  783. /* SysPenField class                                                        */
  784. /****************************************************************************/
  785.  
  786. struct SysPenField_Data
  787. {
  788.     LONG dummy;
  789. };
  790.  
  791.  
  792. ULONG SysPenField_DragQuery(struct IClass *cl,Object *obj,struct MUIP_DragQuery *msg)
  793. {
  794.     if (msg->obj==obj)
  795.         return(MUIV_DragQuery_Refuse);
  796.  
  797.     if (muiUserData(msg->obj)<1 || muiUserData(msg->obj)>8)
  798.         return(MUIV_DragQuery_Refuse);
  799.  
  800.     return(MUIV_DragQuery_Accept);
  801. }
  802.  
  803.  
  804.  
  805. ULONG SysPenField_DragDrop(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
  806. {
  807.     set(obj,MUIA_Pendisplay_Reference,msg->obj);
  808.     return(0);
  809. }
  810.  
  811.  
  812. SAVEDS ASM ULONG SysPenField_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  813. {
  814.     switch (msg->MethodID)
  815.     {
  816.         case MUIM_DragQuery  : return(SysPenField_DragQuery  (cl,obj,(APTR)msg));
  817.         case MUIM_DragDrop   : return(SysPenField_DragDrop   (cl,obj,(APTR)msg));
  818.     }
  819.     return(DoSuperMethodA(cl,obj,msg));
  820. }
  821.  
  822.  
  823.  
  824. static Object *MakePalette(void)
  825. {
  826.     Object *obj;
  827.  
  828.     obj = MUI_NewObject(MUIC_Poppen,
  829.         MUIA_CycleChain, 1,
  830.         MUIA_Window_Title, "Adjust Color",
  831.         MUIA_Penadjust_PSIMode, 2,
  832.         MUIA_MaxHeight, 20,
  833.         TAG_DONE);
  834.  
  835.     return(obj);
  836. }
  837.  
  838.  
  839. Object *MakeMUIPen(int nr,Object **adr)
  840. {
  841.     Object *obj;
  842.  
  843.     obj = VGroup, MUIA_Group_Spacing, 1,
  844.         Child, *adr = MUI_NewObject(MUIC_Poppen,
  845.             MUIA_CycleChain, 1,
  846.             MUIA_Window_Title, "Adjust MUI Pen",
  847.             MUIA_Penadjust_PSIMode, 1,
  848.             MUIA_MaxHeight, 20,
  849.             TAG_DONE),
  850.         Child, TextObject,
  851.             MUIA_Text_Contents, GetStr(nr),
  852.             MUIA_Text_PreParse, "\33c",
  853.             MUIA_Font, MUIV_Font_Tiny,
  854.             End,
  855.         End;
  856.  
  857.     return(obj);
  858. }
  859.  
  860.  
  861. Object *MakeSysPen(int nr,Object **adr)
  862. {
  863.     Object *obj;
  864.  
  865.     obj = VGroup, MUIA_Group_Spacing, 1,
  866.         Child, *adr = NewObject(CL_SysPenField->mcc_Class,NULL,
  867.             TextFrame,
  868.             MUIA_Background, MUII_BACKGROUND,
  869.             MUIA_InnerLeft  , 4,
  870.             MUIA_InnerRight , 4,
  871.             MUIA_InnerTop   , 4,
  872.             MUIA_InnerBottom, 4,
  873.             TAG_DONE),
  874.         Child, TextObject,
  875.             MUIA_Font, MUIV_Font_Tiny,
  876.             MUIA_Text_Contents, GetStr(nr),
  877.             MUIA_Text_PreParse, "\33c",
  878.             End,
  879.         End;
  880.  
  881.     return(obj);
  882. }
  883.  
  884.  
  885.  
  886.  
  887. /****************************************************************************/
  888. /* EditPanel class                                                          */
  889. /****************************************************************************/
  890.  
  891. #define ForChilds(group) \
  892. {\
  893.     APTR child,cstate;\
  894.     struct MinList *list;\
  895.     get(group,MUIA_Group_ChildList,&list);\
  896.     cstate=list->mlh_Head;\
  897.     while (child=NextObject(&cstate))
  898.  
  899. #define NextChilds }
  900.  
  901. struct EditPanel_Data
  902. {
  903.     Object *TX_Info;
  904.     /*
  905.     Object *CM_Adjustable;
  906.     */
  907.  
  908.     Object *GR_EditPages;
  909.  
  910.     Object *ST_Name;
  911.     Object *ST_Title;
  912.     Object *ST_Font;
  913.     Object *ST_Background;
  914.     Object *CM_AutoScroll;
  915.     Object *CM_NoDrag;
  916.     Object *CM_Exclusive;
  917.     Object *CM_Interleaved;
  918.     Object *CM_Behind;
  919.     Object *CM_SysDefault;
  920.     Object *CM_AutoClose;
  921.     Object *CM_CloseGadget;
  922.  
  923.     Object *GR_Size;
  924.     Object *LV_Modes;
  925.     Object *LI_Modes;
  926.     Object *CY_Overscan;
  927.     Object *ST_Width;
  928.     Object *ST_Height;
  929.     Object *SL_Depth;
  930.     Object *TX_ModeInfo;
  931.  
  932.     Object *palette[PSD_NUMCOLS];
  933.     Object *syspens[PSD_NUMSYSPENS];
  934.     /*Object *muipens[PSD_NUMMUIPENS];*/
  935.     Object *ColorMenu;
  936.  
  937.     LONG update;
  938. };
  939.  
  940.  
  941. ULONG EditPanel_SetScreen(struct IClass *cl,Object *obj,struct MUIP_EditPanel_SetScreen *msg)
  942. {
  943.     struct EditPanel_Data *data = INST_DATA(cl,obj);
  944.     struct MUI_PubScreenDesc *desc = msg->desc;
  945.     int i;
  946.  
  947.     set(data->ST_Name       ,MUIA_String_Contents ,desc->Name      );
  948.     set(data->ST_Title      ,MUIA_String_Contents ,desc->Title     );
  949.     set(data->ST_Font       ,MUIA_String_Contents ,desc->Font      );
  950.     set(data->ST_Background ,MUIA_String_Contents ,desc->Background);
  951.  
  952.     /*
  953.     set(data->CM_Adjustable ,MUIA_Selected       ,!desc->Foreign   );
  954.     */
  955.     set(data->CM_AutoScroll ,MUIA_Selected       ,desc->AutoScroll );
  956.     set(data->CM_NoDrag     ,MUIA_Selected       ,desc->NoDrag     );
  957.     set(data->CM_Exclusive  ,MUIA_Selected       ,desc->Exclusive  );
  958.     set(data->CM_Interleaved,MUIA_Selected       ,desc->Interleaved);
  959.     set(data->CM_SysDefault ,MUIA_Selected       ,desc->SysDefault );
  960.     set(data->CM_Behind     ,MUIA_Selected       ,desc->Behind     );
  961.     set(data->CM_AutoClose  ,MUIA_Selected       ,desc->AutoClose  );
  962.     set(data->CM_CloseGadget,MUIA_Selected       ,desc->CloseGadget);
  963.  
  964.     set(data->LI_Modes,MUIA_DispIDlist_CurrentID,desc->DisplayID);
  965.  
  966.     setstr(data->ST_Width ,desc->DisplayWidth );
  967.     setstr(data->ST_Height,desc->DisplayHeight);
  968.     set(data->SL_Depth,MUIA_Slider_Level,desc->DisplayDepth);
  969.     set(data->CY_Overscan,MUIA_Cycle_Active,desc->OverscanType);
  970.  
  971.     for (i=0;i<PSD_NUMCOLS;i++)
  972.     {
  973.         set(data->palette[i],MUIA_Pendisplay_RGBcolor,&desc->Palette[i]);
  974.     }
  975.  
  976.     /*
  977.     for (i=0;i<PSD_NUMMUIPENS;i++)
  978.     {
  979.         set(data->muipens[i],MUIA_Pendisplay_Spec,&desc->MUIPens[i]);
  980.     }
  981.     */
  982.  
  983.     for (i=0;i<PSD_NUMSYSPENS;i++)
  984.     {
  985.         if (data->syspens[i])
  986.         {
  987.             BYTE p = desc->SystemPens[i];
  988.             p = BETWEEN(0,p,3) ? p : BETWEEN(-4,p,-1) ? 8+p : 0;
  989.             set(data->syspens[i],MUIA_Pendisplay_Reference,data->palette[p]);
  990.         }
  991.     }
  992.  
  993.     return(0);
  994. }
  995.  
  996.  
  997. ULONG EditPanel_GetScreen(struct IClass *cl,Object *obj,struct MUIP_EditPanel_GetScreen *msg)
  998. {
  999.     struct EditPanel_Data *data = INST_DATA(cl,obj);
  1000.     struct MUI_PubScreenDesc *desc = msg->desc;
  1001.     int i;
  1002.  
  1003.     strcpy(desc->Name      ,getstr(data->ST_Name      ));
  1004.     strcpy(desc->Title     ,getstr(data->ST_Title     ));
  1005.     strcpy(desc->Font      ,getstr(data->ST_Font      ));
  1006.     strcpy(desc->Background,getstr(data->ST_Background));
  1007.  
  1008.     /*
  1009.     desc->Foreign     = !getbool(data->CM_Adjustable );
  1010.     */
  1011.     desc->AutoScroll  = getbool(data->CM_AutoScroll );
  1012.     desc->NoDrag      = getbool(data->CM_NoDrag     );
  1013.     desc->Exclusive   = getbool(data->CM_Exclusive  );
  1014.     desc->Interleaved = getbool(data->CM_Interleaved);
  1015.     desc->SysDefault  = getbool(data->CM_SysDefault );
  1016.     desc->Behind      = getbool(data->CM_Behind     );
  1017.     desc->AutoClose   = getbool(data->CM_AutoClose  );
  1018.     desc->CloseGadget = getbool(data->CM_CloseGadget);
  1019.  
  1020.     desc->DisplayID     = xget(data->LI_Modes,MUIA_DispIDlist_CurrentID);
  1021.     desc->DisplayWidth  = atol(getstr(data->ST_Width ));
  1022.     desc->DisplayHeight = atol(getstr(data->ST_Height));
  1023.  
  1024.     desc->DisplayDepth  = xget(data->SL_Depth,MUIA_Slider_Level);
  1025.     desc->OverscanType  = xget(data->CY_Overscan,MUIA_Cycle_Active);
  1026.  
  1027.     for (i=0;i<PSD_NUMCOLS;i++)
  1028.     {
  1029.         desc->Palette[i] = *((struct MUI_RGBcolor *)xget(data->palette[i],MUIA_Pendisplay_RGBcolor));
  1030.     }
  1031.  
  1032.     /*
  1033.     for (i=0;i<PSD_NUMMUIPENS;i++)
  1034.     {
  1035.         desc->MUIPens[i] = *((struct MUI_PenSpec *)xget(data->muipens[i],MUIA_Pendisplay_Spec));
  1036.     }
  1037.     */
  1038.  
  1039.     for (i=0;i<PSD_NUMSYSPENS;i++)
  1040.     {
  1041.         if (data->syspens[i])
  1042.         {
  1043.             BYTE p = muiUserData(xget(data->syspens[i],MUIA_Pendisplay_Reference));
  1044.             desc->SystemPens[i] = BETWEEN(1,p,4) ? p-1 : p-9;
  1045.         }
  1046.     }
  1047.  
  1048.     return(0);
  1049. }
  1050.  
  1051.  
  1052. ULONG EditPanel_ContextMenuChoice(struct IClass *cl,Object *obj,struct MUIP_ContextMenuChoice *msg)
  1053. {
  1054.     struct PalettePreset
  1055.     {
  1056.         struct MUI_RGBcolor col[8];
  1057.     };
  1058.  
  1059.     static const struct PalettePreset PalettePreset[10] =
  1060.     {
  1061.         // def
  1062.         {
  1063.             {
  1064.             { 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
  1065.             { 0x00000000,0x00000000,0x00000000 },
  1066.             { 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF },
  1067.             { 0x66666666,0x88888888,0xBBBBBBBB },
  1068.             { 0xEEEEEEEE,0x44444444,0x44444444 },
  1069.             { 0x55555555,0xDDDDDDDD,0x55555555 },
  1070.             { 0x00000000,0x44444444,0xDDDDDDDD },
  1071.             { 0xEEEEEEEE,0x99999999,0x00000000 },
  1072.             }
  1073.         },
  1074.         // tint
  1075.         {
  1076.             {
  1077.             { 0xCCCCCCCC,0xCCCCCCCC,0xBBBBBBBB },
  1078.             { 0x00000000,0x00000000,0x33333333 },
  1079.             { 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF },
  1080.             { 0x99999999,0xAAAAAAAA,0xBBBBBBBB },
  1081.             { 0xEEEEEEEE,0x44444444,0x44444444 },
  1082.             { 0x55555555,0xDDDDDDDD,0x55555555 },
  1083.             { 0xE0E0E0E0,0xF0F0F0F0,0x88888888 },
  1084.             { 0x00000000,0x44444444,0xDDDDDDDD },
  1085.             }
  1086.         },
  1087.         // pharao
  1088.         {
  1089.             {
  1090.             { 0x55555555,0xBBBBBBBB,0xAAAAAAAA },
  1091.             { 0x00000000,0x00000000,0x22222222 },
  1092.             { 0xEEEEEEEE,0xEEEEEEEE,0xFFFFFFFF },
  1093.             { 0x55555555,0x77777777,0xAAAAAAAA },
  1094.             { 0xF6F6F6F6,0xF6F6F6F6,0x00000000 },
  1095.             { 0x62626262,0x51515151,0xF0F0F0F0 },
  1096.             { 0x00000000,0xF0F0F0F0,0x00000000 },
  1097.             { 0xF0F0F0F0,0x30303030,0x10101010 },
  1098.             }
  1099.         },
  1100.         // sunset
  1101.         {
  1102.             {
  1103.             { 0xAAAAAAAA,0x99999999,0x88888888 },
  1104.             { 0x33333333,0x22222222,0x11111111 },
  1105.             { 0xFFFFFFFF,0xEEEEEEEE,0xEEEEEEEE },
  1106.             { 0xFFFFFFFF,0xDDDDDDDD,0xBBBBBBBB },
  1107.             { 0xEEEEEEEE,0x44444444,0x44444444 },
  1108.             { 0x55555555,0xDDDDDDDD,0x55555555 },
  1109.             { 0xCFCFCFCF,0xDBDBDBDB,0xFFFFFFFF },
  1110.             { 0x00000000,0x44444444,0xDDDDDDDD },
  1111.             }
  1112.         },
  1113.         // ocean
  1114.         {
  1115.             {
  1116.             { 0x88888888,0xAAAAAAAA,0xCCCCCCCC },
  1117.             { 0x00000000,0x00000000,0x22222222 },
  1118.             { 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF },
  1119.             { 0xFFFFFFFF,0xCCCCCCCC,0x99999999 },
  1120.             { 0x00000000,0x00000000,0xF0F0F0F0 },
  1121.             { 0xF9F9F9F9,0x21212121,0x21212121 },
  1122.             { 0x52525252,0xF2F2F2F2,0x76767676 },
  1123.             { 0xDFDFDFDF,0xA5A5A5A5,0x26262626 },
  1124.             }
  1125.         },
  1126.         // steel
  1127.         {
  1128.             {
  1129.             { 0x99999999,0xBBBBBBBB,0xDDDDDDDD },
  1130.             { 0x00000000,0x00000000,0x22222222 },
  1131.             { 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF },
  1132.             { 0x66666666,0x88888888,0xBBBBBBBB },
  1133.             { 0xB2B2B2B2,0xDEDEDEDE,0xFFFFFFFF },
  1134.             { 0xFFFFFFFF,0xA1A1A1A1,0x1C1C1C1C },
  1135.             { 0xF0F0F0F0,0x44444444,0x87878787 },
  1136.             { 0xBFBFBFBF,0xFFFFFFFF,0x90909090 },
  1137.             }
  1138.         },
  1139.         // chocolate
  1140.         {
  1141.             {
  1142.             { 0xBBBBBBBB,0xAAAAAAAA,0x99999999 },
  1143.             { 0x00000000,0x00000000,0x22222222 },
  1144.             { 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF },
  1145.             { 0x66666666,0x88888888,0xBBBBBBBB },
  1146.             { 0xEEEEEEEE,0x44444444,0x44444444 },
  1147.             { 0x55555555,0xDDDDDDDD,0x55555555 },
  1148.             { 0x00000000,0x44444444,0xDDDDDDDD },
  1149.             { 0xEEEEEEEE,0x99999999,0x00000000 },
  1150.             }
  1151.         },
  1152.         // pewter
  1153.         {
  1154.             {
  1155.             { 0x88888888,0xAAAAAAAA,0xCCCCCCCC },
  1156.             { 0x00000000,0x00000000,0x22222222 },
  1157.             { 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF },
  1158.             { 0xEEEEEEEE,0x99999999,0x77777777 },
  1159.             { 0xD9D9D9D9,0xFFFFFFFF,0x09090909 },
  1160.             { 0xF0F0F0F0,0x2D2D2D2D,0x31313131 },
  1161.             { 0x38383838,0xF2F2F2F2,0x38383838 },
  1162.             { 0x44444444,0x49494949,0xF0F0F0F0 },
  1163.             }
  1164.         },
  1165.         // wine
  1166.         {
  1167.             {
  1168.             { 0xCCCCCCCC,0x99999999,0x99999999 },
  1169.             { 0x00000000,0x00000000,0x22222222 },
  1170.             { 0xFFFFFFFF,0xEEEEEEEE,0xEEEEEEEE },
  1171.             { 0xBBBBBBBB,0x66666666,0x77777777 },
  1172.             { 0xE0E0E0E0,0xF0F0F0F0,0x88888888 },
  1173.             { 0x79797979,0x46464646,0xE8E8E8E8 },
  1174.             { 0x60606060,0xC7C7C7C7,0x52525252 },
  1175.             { 0x89898989,0xEAEAEAEA,0xC8C8C8C8 },
  1176.             }
  1177.         },
  1178.         // magicwb
  1179.         {
  1180.             {
  1181.             { 0x95959595,0x95959595,0x95959595 },
  1182.             { 0x00000000,0x00000000,0x00000000 },
  1183.             { 0xffffffff,0xffffffff,0xffffffff },
  1184.             { 0x3b3b3b3b,0x67676767,0xa2a2a2a2 },
  1185.             { 0x7b7b7b7b,0x7b7b7b7b,0x7b7b7b7b },
  1186.             { 0xafafafaf,0xafafafaf,0xafafafaf },
  1187.             { 0xaaaaaaaa,0x90909090,0x7c7c7c7c },
  1188.             { 0xffffffff,0xa9a9a9a9,0x97979797 },
  1189.             }
  1190.         },
  1191.     };
  1192.     /*{   0, 1, 1, 2, 1, 3, 1, 0, 2, 1, 2, 1 }*/
  1193.  
  1194.     LONG i = muiUserData(msg->item);
  1195.     struct MUI_PubScreenDesc *desc = NULL;
  1196.     struct MUI_RGBcolor *new = NULL;
  1197.     struct EditPanel_Data *data = INST_DATA(cl,obj);
  1198.  
  1199.     if (i>=0 && i<10)
  1200.     {
  1201.         new = (struct MUI_RGBcolor *)PalettePreset[i].col;
  1202.     }
  1203.     else if (i==10)
  1204.     {
  1205.         if (desc = MUIS_AllocPubScreenDesc(NULL))
  1206.         {
  1207.             new = desc->Palette;
  1208.         }
  1209.     }
  1210.  
  1211.     if (new)
  1212.     {
  1213.         for (i=0;i<PSD_NUMCOLS;i++)
  1214.         {
  1215.             set(data->palette[i],MUIA_Pendisplay_RGBcolor,&new[i]);
  1216.         }
  1217.     }
  1218.  
  1219.     if (desc)
  1220.         MUIS_FreePubScreenDesc(desc);
  1221.  
  1222.     return(0);
  1223. }
  1224.  
  1225.  
  1226. ULONG EditPanel_New(struct IClass *cl,Object *obj,struct opSet *msg)
  1227. {
  1228.     struct EditPanel_Data tmp = {0};
  1229.     Object *l1,*l2;
  1230.  
  1231.     obj = (Object *)DoSuperNew(cl,obj,
  1232.         MUIA_Group_Horiz, FALSE,
  1233.  
  1234.         MUIA_ContextMenu, tmp.ColorMenu = MUI_MakeObject(MUIO_MenustripNM,PaletteMenu,MUIO_MenustripNM_CommandKeyCheck),
  1235.  
  1236.         /*
  1237.         Child, HGroup, GroupSpacing(1),
  1238.             MUIA_Weight, 0,
  1239.             */
  1240.             Child, tmp.TX_Info = TextObject,TextFrame,MUIA_Background,MUII_TextBack,MUIA_Text_PreParse,"\33c",End,
  1241.             /*
  1242.             Child, tmp.CM_Adjustable = MUI_MakeObject(MUIO_Checkmark,NULL),
  1243.             End,
  1244.             */
  1245.  
  1246.         Child, tmp.GR_EditPages = RegisterGroup(CYA_EditPages),
  1247.             MUIA_CycleChain, 1,
  1248.  
  1249.             Child, ColGroup(2),
  1250.                 Child, MakeLabel2(MSG_LABEL_PUBLICNAME),
  1251.                 Child, tmp.ST_Name = MUI_NewObject(MUIC_Popscreen,
  1252.                     MUIA_Popstring_String, MakeString(PSD_MAXLEN_NAME,MSG_LABEL_PUBLICNAME),
  1253.                     MUIA_Popstring_Button, PopButton(MUII_PopUp),
  1254.                     TAG_DONE),
  1255.                 Child, MakeLabel2(MSG_LABEL_SCREENTITLE), Child, tmp.ST_Title = MakeString(PSD_MAXLEN_TITLE,MSG_LABEL_SCREENTITLE),
  1256.                 Child, MakeLabel2(MSG_LABEL_DEFAULTFONT), Child, tmp.ST_Font  = PopaslObject, MUIA_Popstring_String, MakeString(PSD_MAXLEN_FONT,MSG_LABEL_DEFAULTFONT), MUIA_Popstring_Button, PopButton(MUII_PopUp), MUIA_Popasl_Type, ASL_FontRequest, End,
  1257.                 Child, MakeLabel2(MSG_LABEL_BACKGROUND ), Child, tmp.ST_Background = PopaslObject, MUIA_Popstring_String, MakeString(PSD_MAXLEN_BACKGROUND,MSG_LABEL_BACKGROUND), MUIA_Popstring_Button, PopButton(MUII_PopUp), MUIA_Popasl_Type, ASL_FileRequest, End,
  1258.                 Child, VSpace(2), Child, VSpace(2),
  1259.                 Child, MakeFreeLabel(MSG_LABEL_PUBLICFLAGS),
  1260.                 Child, HGroup,
  1261.                     Child, ColGroup(2),
  1262.                         Child, tmp.CM_AutoScroll  = MakeCheck(MSG_LABEL_AUTOSCROLL   ), Child, MakeLLabel1(MSG_LABEL_AUTOSCROLL   ),
  1263.                         Child, tmp.CM_NoDrag      = MakeCheck(MSG_LABEL_NODRAG       ), Child, MakeLLabel1(MSG_LABEL_NODRAG       ),
  1264.                         Child, tmp.CM_Exclusive   = MakeCheck(MSG_LABEL_EXCLUSIVE    ), Child, MakeLLabel1(MSG_LABEL_EXCLUSIVE    ),
  1265.                         End,
  1266.                     Child, HSpace(0),
  1267.                     Child, ColGroup(2),
  1268.                         Child, tmp.CM_AutoClose   = MakeCheck(MSG_LABEL_AUTOCLOSE    ), Child, MakeLLabel1(MSG_LABEL_AUTOCLOSE    ),
  1269.                         Child, tmp.CM_Interleaved = MakeCheck(MSG_LABEL_INTERLEAVED  ), Child, MakeLLabel1(MSG_LABEL_INTERLEAVED  ),
  1270.                         Child, tmp.CM_Behind      = MakeCheck(MSG_LABEL_OPENBEHIND   ), Child, MakeLLabel1(MSG_LABEL_OPENBEHIND   ),
  1271.                         End,
  1272.                     Child, HSpace(0),
  1273.                     Child, ColGroup(2),
  1274.                         Child, tmp.CM_SysDefault  = MakeCheck(MSG_LABEL_SYSTEMDEFAULT), Child, MakeLLabel1(MSG_LABEL_SYSTEMDEFAULT),
  1275.                         Child, tmp.CM_CloseGadget = MakeCheck(MSG_LABEL_CLOSEGADGET  ), Child, MakeLLabel1(MSG_LABEL_CLOSEGADGET  ),
  1276.                         Child, VSpace(0), Child, VSpace(0),
  1277.                         End,
  1278.                     End,
  1279.                 End,
  1280.  
  1281.             Child, HGroup,
  1282.                 Child, tmp.LV_Modes = ListviewObject,
  1283.                     MUIA_CycleChain, 1,
  1284.                     MUIA_Listview_List, tmp.LI_Modes = NewObject(CL_DispIDlist->mcc_Class,NULL,
  1285.                         InputListFrame,
  1286.                         MUIA_List_AdjustWidth, TRUE,
  1287.                         TAG_DONE),
  1288.                     End,
  1289.                 Child, VGroup,
  1290.                     Child, ScrollgroupObject,
  1291.                         MUIA_Scrollgroup_FreeHoriz, FALSE,
  1292.                   MUIA_Scrollgroup_Contents, VirtgroupObject,
  1293.                             TextFrame,
  1294.                             GroupSpacing(0),
  1295.                             MUIA_Group_Horiz, TRUE,
  1296.                             Child, tmp.TX_ModeInfo = NewObject(CL_DispIDinfo->mcc_Class,NULL,TAG_DONE),
  1297.                             Child, HSpace(0),
  1298.                             End,
  1299.                         End,
  1300.                     Child, RectangleObject, MUIA_VertWeight, 1, End,
  1301.                     Child, tmp.GR_Size = ColGroup(2),
  1302.                         Child, MakeLabel1(MSG_LABEL_OVERSCAN), Child, tmp.CY_Overscan = MakeCycle(CYA_Overscan,MSG_LABEL_OVERSCAN),
  1303.                         Child, MakeLabel2(MSG_LABEL_SIZE),
  1304.                         Child, HGroup,
  1305.                             Child, tmp.ST_Width = MakeString(8,MSG_LABEL_SIZE),
  1306.                             Child, MakeLabel2(MSG_LABEL_CROSS),
  1307.                             Child, tmp.ST_Height = MakeString(8,MSG_LABEL_CROSS),
  1308.                             End,
  1309.                         Child, MakeLabel2(MSG_LABEL_DEPTH), Child, tmp.SL_Depth = MakeSlider(1,24,MSG_LABEL_DEPTH),
  1310.                         End,
  1311.                     End,
  1312.                 End,
  1313.  
  1314.             Child, VGroup,
  1315.                 Child, ColGroup(3),
  1316.                     GroupFrameT(GetStr(MSG_PALETTE_TITLE)),
  1317.                     MUIA_Group_VertSpacing, 1,
  1318.                     Child, l1 = MakeCLabel(MSG_PALETTE_FIRST),
  1319.                     Child, HSpace(4),
  1320.                     Child, l2 = MakeCLabel(MSG_PALETTE_LAST),
  1321.                     Child, HGroup,
  1322.                         Child, tmp.palette[0] = MakePalette(),
  1323.                         Child, tmp.palette[1] = MakePalette(),
  1324.                         Child, tmp.palette[2] = MakePalette(),
  1325.                         Child, tmp.palette[3] = MakePalette(),
  1326.                         End,
  1327.                     Child, HSpace(4),
  1328.                     Child, HGroup,
  1329.                         Child, tmp.palette[4] = MakePalette(),
  1330.                         Child, tmp.palette[5] = MakePalette(),
  1331.                         Child, tmp.palette[6] = MakePalette(),
  1332.                         Child, tmp.palette[7] = MakePalette(),
  1333.                         End,
  1334.                     End,
  1335.                 Child, HGroup,
  1336.                     Child, ColGroup(3),
  1337.                         GroupFrameT(GetStr(MSG_SYSPENS_TITLE)),
  1338.                         Child, MakeSysPen(MSG_SYSPEN_TEXT     ,&tmp.syspens[TEXTPEN         ]),
  1339.                         Child, MakeSysPen(MSG_SYSPEN_SHINE    ,&tmp.syspens[SHINEPEN        ]),
  1340.                         Child, MakeSysPen(MSG_SYSPEN_SHADOW   ,&tmp.syspens[SHADOWPEN       ]),
  1341.                         Child, MakeSysPen(MSG_SYSPEN_FILL     ,&tmp.syspens[FILLPEN         ]),
  1342.                         Child, MakeSysPen(MSG_SYSPEN_FILLTEXT ,&tmp.syspens[FILLTEXTPEN     ]),
  1343.                         Child, MakeSysPen(MSG_SYSPEN_HIGHLIGHT,&tmp.syspens[HIGHLIGHTTEXTPEN]),
  1344.                         Child, MakeSysPen(MSG_SYSPEN_BARDETAIL,&tmp.syspens[BARDETAILPEN    ]),
  1345.                         Child, MakeSysPen(MSG_SYSPEN_BARBLOCK ,&tmp.syspens[BARBLOCKPEN     ]),
  1346.                         Child, MakeSysPen(MSG_SYSPEN_BARTRIM  ,&tmp.syspens[BARTRIMPEN      ]),
  1347.                         End,
  1348.                     /*
  1349.                     Child, VGroup,
  1350.                         GroupFrameT(GetStr(MSG_MUIPENS_TITLE)),
  1351.                         Child, ColGroup(3),
  1352.                             Child, MakeMUIPen(MSG_MUIPEN_SHINE     ,&tmp.muipens[MPEN_SHINE     ]),
  1353.                             Child, MakeMUIPen(MSG_MUIPEN_HALFSHINE ,&tmp.muipens[MPEN_HALFSHINE ]),
  1354.                             Child, MakeMUIPen(MSG_MUIPEN_BACKGROUND,&tmp.muipens[MPEN_BACKGROUND]),
  1355.                             Child, MakeMUIPen(MSG_MUIPEN_HALFSHADOW,&tmp.muipens[MPEN_HALFSHADOW]),
  1356.                             Child, MakeMUIPen(MSG_MUIPEN_SHADOW    ,&tmp.muipens[MPEN_SHADOW    ]),
  1357.                             Child, MakeMUIPen(MSG_MUIPEN_TEXT      ,&tmp.muipens[MPEN_TEXT      ]),
  1358.                             Child, MakeMUIPen(MSG_MUIPEN_FILL      ,&tmp.muipens[MPEN_FILL      ]),
  1359.                             Child, MakeMUIPen(MSG_MUIPEN_MARK      ,&tmp.muipens[MPEN_MARK      ]),
  1360.                             End,
  1361.                         End,
  1362.                     */
  1363.                     End,
  1364.                 End,
  1365.  
  1366.             End,
  1367.         TAG_MORE,msg->ops_AttrList);
  1368.  
  1369.     if (obj)
  1370.     {
  1371.         struct EditPanel_Data *data = INST_DATA(cl,obj);
  1372.         int i;
  1373.  
  1374.         *data = tmp;
  1375.  
  1376.         DoMethod(tmp.LI_Modes     ,MUIM_Notify,MUIA_DispIDlist_CurrentID,MUIV_EveryTime,obj,2,MUIM_EditPanel_Update,3);
  1377.         DoMethod(tmp.CY_Overscan  ,MUIM_Notify,MUIA_Cycle_Active        ,MUIV_EveryTime,obj,2,MUIM_EditPanel_Update,2);
  1378.         DoMethod(tmp.ST_Width     ,MUIM_Notify,MUIA_String_Acknowledge  ,MUIV_EveryTime,obj,2,MUIM_EditPanel_Update,1);
  1379.         DoMethod(tmp.ST_Height    ,MUIM_Notify,MUIA_String_Acknowledge  ,MUIV_EveryTime,obj,2,MUIM_EditPanel_Update,1);
  1380.         DoMethod(tmp.SL_Depth     ,MUIM_Notify,MUIA_Slider_Level        ,MUIV_EveryTime,obj,2,MUIM_EditPanel_Update,1);
  1381.  
  1382.         /*
  1383.         set(tmp.CM_Adjustable,MUIA_Selected,TRUE);
  1384.         DoMethod(tmp.CM_Adjustable,MUIM_Notify,MUIA_Selected            ,MUIV_EveryTime,obj,1,MUIM_EditPanel_ToggleForeign);
  1385.         */
  1386.  
  1387.         set(tmp.TX_Info       ,MUIA_ShortHelp,GetStr(MSG_HELP_INFO         ));
  1388.         /*
  1389.         set(tmp.CM_Adjustable ,MUIA_ShortHelp,GetStr(MSG_HELP_ADJUSTABLE   ));
  1390.         */
  1391.         set(tmp.ST_Name       ,MUIA_ShortHelp,GetStr(MSG_HELP_NAME         ));
  1392.         set(tmp.ST_Title      ,MUIA_ShortHelp,GetStr(MSG_HELP_TITLE        ));
  1393.         set(tmp.ST_Font       ,MUIA_ShortHelp,GetStr(MSG_HELP_FONT         ));
  1394.         set(tmp.ST_Background ,MUIA_ShortHelp,GetStr(MSG_HELP_BACKGROUND   ));
  1395.         set(tmp.CM_AutoScroll ,MUIA_ShortHelp,GetStr(MSG_HELP_AUTOSCROLL   ));
  1396.         set(tmp.CM_NoDrag     ,MUIA_ShortHelp,GetStr(MSG_HELP_NODRAG       ));
  1397.         set(tmp.CM_Exclusive  ,MUIA_ShortHelp,GetStr(MSG_HELP_EXCLUSIVE    ));
  1398.         set(tmp.CM_Interleaved,MUIA_ShortHelp,GetStr(MSG_HELP_INTERLEAVED  ));
  1399.         set(tmp.CM_Behind     ,MUIA_ShortHelp,GetStr(MSG_HELP_BEHIND       ));
  1400.         set(tmp.CM_AutoClose  ,MUIA_ShortHelp,GetStr(MSG_HELP_AUTOCLOSE    ));
  1401.         set(tmp.CM_CloseGadget,MUIA_ShortHelp,GetStr(MSG_HELP_CLOSEGADGET  ));
  1402.         set(tmp.CM_SysDefault ,MUIA_ShortHelp,GetStr(MSG_HELP_SYSTEMDEFAULT));
  1403.         set(tmp.LV_Modes      ,MUIA_ShortHelp,GetStr(MSG_HELP_MODELIST     ));
  1404.         set(tmp.CY_Overscan   ,MUIA_ShortHelp,GetStr(MSG_HELP_OVERSCAN     ));
  1405.         set(tmp.ST_Width      ,MUIA_ShortHelp,GetStr(MSG_HELP_WIDTH        ));
  1406.         set(tmp.ST_Height     ,MUIA_ShortHelp,GetStr(MSG_HELP_HEIGHT       ));
  1407.         set(tmp.SL_Depth      ,MUIA_ShortHelp,GetStr(MSG_HELP_DEPTH        ));
  1408.         set(tmp.TX_ModeInfo   ,MUIA_ShortHelp,GetStr(MSG_HELP_MODEINFO     ));
  1409.  
  1410.         for (i=0;i<8;i++)
  1411.             set(data->palette[i],MUIA_UserData,i+1);
  1412.  
  1413.         set(l1,MUIA_Font,MUIV_Font_Tiny);
  1414.         set(l2,MUIA_Font,MUIV_Font_Tiny);
  1415.  
  1416.         /*
  1417.         DoMethod(obj,MUIM_EditPanel_ToggleForeign);
  1418.         */
  1419.  
  1420.         if (IntuitionBase->lib_Version<39)
  1421.             set(tmp.ST_Background,MUIA_Disabled,TRUE);
  1422.  
  1423.         return((ULONG)obj);
  1424.     }
  1425.  
  1426.     return(0);
  1427. }
  1428.  
  1429.  
  1430. ULONG EditPanel_Dispose(struct IClass *cl,Object *obj,Msg msg)
  1431. {
  1432.     struct EditPanel_Data *data = INST_DATA(cl,obj);
  1433.  
  1434.     if (data->ColorMenu)
  1435.         MUI_DisposeObject(data->ColorMenu);
  1436.  
  1437.     return(DoSuperMethodA(cl,obj,msg));
  1438. }
  1439.  
  1440.  
  1441. /*
  1442. ULONG EditPanel_ToggleForeign(struct IClass *cl,Object *obj,Msg msg)
  1443. {
  1444.     struct EditPanel_Data *data = INST_DATA(cl,obj);
  1445.     BOOL disable = !getbool(data->CM_Adjustable);
  1446.  
  1447.     if (disable)
  1448.         set(data->GR_EditPages,MUIA_Group_ActivePage,2);
  1449.  
  1450.     DoMethod(obj,MUIM_EditPanel_Update,1);
  1451.  
  1452.     DoMethod(obj,MUIM_MultiSet,MUIA_Disabled,disable,
  1453.         data->ST_Title,
  1454.         data->ST_Font,
  1455.         data->ST_Background,
  1456.         data->CM_AutoScroll,
  1457.         data->CM_NoDrag,
  1458.         data->CM_Exclusive,
  1459.         data->CM_Interleaved,
  1460.         data->CM_Behind,
  1461.         data->CM_SysDefault,
  1462.         data->CM_AutoClose,
  1463.         data->CM_CloseGadget,
  1464.         data->LV_Modes,
  1465.         data->CY_Overscan,
  1466.         data->ST_Width,
  1467.         data->ST_Height,
  1468.         data->SL_Depth,
  1469.         data->TX_ModeInfo,
  1470.         NULL);
  1471.  
  1472.     return(0);
  1473. }
  1474. */
  1475.  
  1476.  
  1477. ULONG EditPanel_Update(struct IClass *cl,Object *obj,struct MUIP_EditPanel_Update *msg)
  1478. {
  1479.     struct EditPanel_Data *data = INST_DATA(cl,obj);
  1480.     struct NameInfo *ni;
  1481.     struct DimensionInfo DimensionInfo;
  1482.  
  1483.     if (data->update) return(0);
  1484.     data->update = TRUE;
  1485.  
  1486.     /*
  1487.     if (getbool(data->CM_Adjustable))
  1488.     */
  1489.     {
  1490.         DoMethod(data->LI_Modes,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&ni);
  1491.  
  1492.         if (ni && GetDisplayInfoData(NULL,(char *)&DimensionInfo,sizeof(DimensionInfo),DTAG_DIMS,ni->Header.DisplayID))
  1493.         {
  1494.             /*set(data->GR_SysPots,MUIA_Coloradjust_ModeID,ni->Header.DisplayID); !!!*/
  1495.  
  1496.             if (msg->level>=1)
  1497.             {
  1498.                 set(data->GR_Size,MUIA_Disabled,FALSE);
  1499.                 set(data->SL_Depth,MUIA_Slider_Max,DimensionInfo.MaxDepth);
  1500.             }
  1501.  
  1502.             if (msg->level>=3)
  1503.                 set(data->TX_ModeInfo,MUIA_DispIDinfo_ID,ni->Header.DisplayID);
  1504.  
  1505.             if (msg->level>=2)
  1506.             {
  1507.                 int w = RectangleWidth(DimensionInfo.TxtOScan);
  1508.                 int h = RectangleHeight(DimensionInfo.TxtOScan);
  1509.  
  1510.                 switch (xget(data->CY_Overscan,MUIA_Cycle_Active))
  1511.                 {
  1512.                     case 1:
  1513.                         w = RectangleWidth(DimensionInfo.StdOScan);
  1514.                         h = RectangleHeight(DimensionInfo.StdOScan);
  1515.                         break;
  1516.  
  1517.                     case 2:
  1518.                         w = RectangleWidth(DimensionInfo.MaxOScan);
  1519.                         h = RectangleHeight(DimensionInfo.MaxOScan);
  1520.                         break;
  1521.  
  1522.                     case 3:
  1523.                         w = RectangleWidth(DimensionInfo.VideoOScan);
  1524.                         h = RectangleHeight(DimensionInfo.VideoOScan);
  1525.                         break;
  1526.                 }
  1527.  
  1528.                 setstr(data->ST_Width ,w);
  1529.                 setstr(data->ST_Height,h);
  1530.             }
  1531.  
  1532.             if (msg->level>=1)
  1533.                 DoMethod(data->TX_Info,MUIM_SetAsString,MUIA_Text_Contents,"%s (%ld x %ld x %ld)",ni->Name,atol(getstr(data->ST_Width)),atol(getstr(data->ST_Height)),xget(data->SL_Depth,MUIA_Slider_Level));
  1534.         }
  1535.         else
  1536.         {
  1537.             /* set(data->GR_SysPots,MUIA_Coloradjust_ModeID,INVALID_ID); !!!*/
  1538.             set(data->TX_ModeInfo,MUIA_DispIDinfo_ID,INVALID_ID);
  1539.             set(data->TX_Info,MUIA_Text_Contents,GetStr(MSG_TEXT_UNKNOWNMODE));
  1540.             set(data->GR_Size,MUIA_Disabled,TRUE);
  1541.         }
  1542.     }
  1543.     /*
  1544.     else
  1545.     {
  1546.         set(data->TX_Info,MUIA_Text_Contents,GetStr(MSG_TEXT_FOREIGNSCREEN));
  1547.     }
  1548.     */
  1549.  
  1550.     data->update = FALSE;
  1551.     return(0);
  1552. }
  1553.  
  1554.  
  1555. SAVEDS ASM ULONG EditPanel_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  1556. {
  1557.     switch (msg->MethodID)
  1558.     {
  1559.         case OM_NEW                      : return(EditPanel_New              (cl,obj,(APTR)msg));
  1560.         case OM_DISPOSE                  : return(EditPanel_Dispose          (cl,obj,(APTR)msg));
  1561.  
  1562.         case MUIM_ContextMenuChoice      : return(EditPanel_ContextMenuChoice(cl,obj,(APTR)msg));
  1563.  
  1564.         case MUIM_EditPanel_SetScreen    : return(EditPanel_SetScreen        (cl,obj,(APTR)msg));
  1565.         case MUIM_EditPanel_GetScreen    : return(EditPanel_GetScreen        (cl,obj,(APTR)msg));
  1566.         case MUIM_EditPanel_Update       : return(EditPanel_Update           (cl,obj,(APTR)msg));
  1567.         /*
  1568.         case MUIM_EditPanel_ToggleForeign: return(EditPanel_ToggleForeign    (cl,obj,(APTR)msg));
  1569.         */
  1570.     }
  1571.     return(DoSuperMethodA(cl,obj,msg));
  1572. }
  1573.  
  1574.  
  1575.  
  1576. /****************************************************************************/
  1577. /* EditWindow class                                                         */
  1578. /****************************************************************************/
  1579.  
  1580. struct EditWindow_Data
  1581. {
  1582.     Object *panel;
  1583.     char wtitle[PSD_MAXLEN_TITLE+20];
  1584. };
  1585.  
  1586. ULONG EditWindow_New(struct IClass *cl,Object *obj,struct opSet *msg)
  1587. {
  1588.     struct EditWindow_Data *data;
  1589.     Object *ok;
  1590.     Object *cancel;
  1591.     Object *panel;
  1592.     Object *originator;
  1593.     /*Object *strip;*/
  1594.  
  1595.     if (obj = (Object *)DoSuperNew(cl,obj,
  1596.         /*MUIA_Window_Menustrip, strip = MUI_MakeObject(MUIO_MenustripNM,EditMenu,0),*/
  1597.         WindowContents, VGroup,
  1598.             Child, panel = NewObject(CL_EditPanel->mcc_Class,NULL,TAG_DONE),
  1599.             Child, HGroup, MUIA_Group_SameSize, TRUE,
  1600.                 Child, ok = MakeButton(MSG_BUTTON_OK),
  1601.                 Child, HSpace(0),
  1602.                 Child, HSpace(0),
  1603.                 Child, HSpace(0),
  1604.                 Child, cancel = MakeButton(MSG_BUTTON_CANCEL),
  1605.                 End,
  1606.             End,
  1607.         TAG_MORE,msg->ops_AttrList))
  1608.     {
  1609.         data = INST_DATA(cl,obj);
  1610.  
  1611.         data->panel = panel;
  1612.  
  1613.         strcpy(data->wtitle,GetStr(MSG_TITLE_PUBSCREENWINDOW));
  1614.         strcat(data->wtitle," ");
  1615.         strcat(data->wtitle,(char *)GetTagData(MUIA_EditWindow_Title,(ULONG)"",msg->ops_AttrList));
  1616.  
  1617.         set(obj,MUIA_Window_Title,data->wtitle);
  1618.         set(obj,MUIA_Window_ID   ,MAKE_ID('E','D','I','T'));
  1619.  
  1620.         originator = (Object *)GetTagData(MUIA_EditWindow_Originator,0,msg->ops_AttrList);
  1621.  
  1622.         DoMethod(obj   ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE ,MUIV_Notify_Application,6,MUIM_Application_PushMethod,originator,3,MUIM_ScreenPanel_Finish,obj,FALSE);
  1623.         DoMethod(cancel,MUIM_Notify,MUIA_Pressed            ,FALSE,MUIV_Notify_Application,6,MUIM_Application_PushMethod,originator,3,MUIM_ScreenPanel_Finish,obj,FALSE);
  1624.         DoMethod(ok    ,MUIM_Notify,MUIA_Pressed            ,FALSE,MUIV_Notify_Application,6,MUIM_Application_PushMethod,originator,3,MUIM_ScreenPanel_Finish,obj,TRUE );
  1625.  
  1626.         /*
  1627.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_2COL),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,panel,2,MUIM_EditPanel_DefColors,0);
  1628.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_4COL),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,panel,2,MUIM_EditPanel_DefColors,1);
  1629.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_8COL),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,panel,2,MUIM_EditPanel_DefColors,2);
  1630.         */
  1631.  
  1632.         set(ok    ,MUIA_ShortHelp,GetStr(MSG_HELP_EDITOK    ));
  1633.         set(cancel,MUIA_ShortHelp,GetStr(MSG_HELP_EDITCANCEL));
  1634.  
  1635.         return((ULONG)obj);
  1636.     }
  1637.     return(0);
  1638. }
  1639.  
  1640. SAVEDS ASM ULONG EditWindow_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  1641. {
  1642.     switch (msg->MethodID)
  1643.     {
  1644.         case OM_NEW: return(EditWindow_New(cl,obj,(APTR)msg));
  1645.  
  1646.         /*
  1647.         **    The next methods actually don't belong to the
  1648.         ** edit window class. We just forward them here to
  1649.         ** allow treating an edit window much like an edit
  1650.         ** panel from outside.
  1651.         */
  1652.  
  1653.         case MUIM_EditPanel_SetScreen:
  1654.         case MUIM_EditPanel_GetScreen:
  1655.         {
  1656.             struct EditWindow_Data *data = INST_DATA(cl,obj);
  1657.             return(DoMethodA(data->panel,msg));
  1658.         }
  1659.     }
  1660.     return(DoSuperMethodA(cl,obj,msg));
  1661. }
  1662.  
  1663.  
  1664.  
  1665. /****************************************************************************/
  1666. /* ScreenList class                                                         */
  1667. /****************************************************************************/
  1668.  
  1669. #define USE_PSI_SCREENON_HEADER
  1670. #define USE_PSI_SCREENON_BODY
  1671. #define USE_PSI_SCREENON_COLORS
  1672. #include "psi_screenon.bh"
  1673.  
  1674. /*
  1675. #define USE_PSI_SCREENOF_BODY
  1676. #include "psi_screenof.bh"
  1677. */
  1678.  
  1679. #define USE_PSI_SCREENCN_BODY
  1680. #include "psi_screencn.bh"
  1681.  
  1682. /*
  1683. #define USE_PSI_SCREENCF_BODY
  1684. #include "psi_screencf.bh"
  1685. */
  1686.  
  1687.  
  1688.  
  1689. struct ScreenList_Data
  1690. {
  1691.     Object *list;
  1692.     Object *onormal[2];
  1693.     /*
  1694.     Object *oforeign[2];
  1695.     */
  1696.     APTR inormal[2];
  1697.     /*
  1698.     APTR iforeign[2];
  1699.     */
  1700.     struct Hook DisplayHook;
  1701. };
  1702.  
  1703. SAVEDS ASM APTR ScreenList_ConstructFunc(REG(a1) struct MUI_PubScreenDesc *src)
  1704. {
  1705.     struct MUI_PubScreenDesc *desc;
  1706.  
  1707.     if (desc = MUIS_AllocPubScreenDesc(src))
  1708.     {
  1709.         desc->Changed  = FALSE;
  1710.         desc->UserData = NULL;
  1711.     }
  1712.     return(desc);
  1713. }
  1714.  
  1715. SAVEDS ASM VOID ScreenList_DestructFunc(REG(a1) struct MUI_PubScreenDesc *desc)
  1716. {
  1717.     MUIS_FreePubScreenDesc(desc);
  1718. }
  1719.  
  1720. SAVEDS ASM LONG ScreenList_CompareFunc(REG(a1) struct MUI_PubScreenDesc *d1,REG(a2) struct MUI_PubScreenDesc *d2)
  1721. {
  1722.     /*
  1723.     if (d1->Foreign && !d2->Foreign)
  1724.         return(-1);
  1725.  
  1726.     if (d2->Foreign && !d1->Foreign)
  1727.         return(1);
  1728.     */
  1729.  
  1730.     if (!strcmp(d1->Name,PSD_INITIAL_NAME))
  1731.         return(strcmp(d2->Name,PSD_INITIAL_NAME) ? 1 : 0);
  1732.     else if (!strcmp(d2->Name,PSD_INITIAL_NAME))
  1733.         return(-1);
  1734.     else
  1735.         return(stricmp(d1->Name,d2->Name));
  1736. }
  1737.  
  1738. SAVEDS ASM LONG ScreenList_DisplayFunc(REG(a0) struct Hook *hook,REG(a2) char **array,REG(a1) struct MUI_PubScreenDesc *desc)
  1739. {
  1740.     struct ScreenList_Data *data = (APTR)hook->h_Data;
  1741.  
  1742.     *array++ = "";
  1743.  
  1744.     if (!desc)
  1745.     {
  1746.         static char buf1[30],buf2[30];
  1747.         strcpy(buf1,"\33b\33u");
  1748.         strcpy(buf2,"\33b\33u");
  1749.         strcat(buf1,GetStr(MSG_LIST_SCREENNAME));
  1750.         strcat(buf2,GetStr(MSG_LIST_SCREENMODE));
  1751.         *array++ = "";
  1752.         *array++ = buf1;
  1753.         *array   = buf2;
  1754.     }
  1755.     else
  1756.     {
  1757.         static struct NameInfo ni;
  1758.         static char buf1[PSD_MAXLEN_NAME+2];
  1759.         static char buf2[50];
  1760.  
  1761.         strcpy(buf1,desc->UserData ? "\33b" : desc->Changed ? "\33u" : "");
  1762.         strcat(buf1,desc->Name);
  1763.  
  1764.         /*
  1765.         if (desc->Foreign)
  1766.         {
  1767.             strcpy(ni.Name,GetStr(MSG_LIST_FOREIGNSCREEN));
  1768.             sprintf(buf2,"\33O[%08lx]",data->iforeign[TestPubScreen(desc->Name) ? 1 : 0]);
  1769.         }
  1770.         else
  1771.         */
  1772.         {
  1773.             if (!GetDisplayInfoData(0,(UBYTE *)&ni,sizeof(ni),DTAG_NAME,desc->DisplayID))
  1774.                 strcpy(ni.Name,GetStr(MSG_LIST_UNKNOWNMODE));
  1775.  
  1776.             sprintf(buf2,"\33O[%08lx]",data->inormal[TestPubScreen(desc->Name) ? 1 : 0]);
  1777.         }
  1778.  
  1779.         *array++ = buf2;
  1780.         *array++ = buf1;
  1781.         *array   = ni.Name;
  1782.     }
  1783.  
  1784.     return(0);
  1785. }
  1786.  
  1787.  
  1788. ULONG ScreenList_Load(struct IClass *cl,Object *obj,struct MUIP_ScreenList_Load *msg)
  1789. {
  1790.     ULONG result = FALSE;
  1791.     struct MUI_PubScreenDesc *desc;
  1792.     APTR pfh;
  1793.  
  1794.     if (pfh = MUIS_OpenPubFile(msg->name,MODE_OLDFILE))
  1795.     {
  1796.         result = TRUE;
  1797.  
  1798.         if (msg->clear)
  1799.             DoMethod(obj,MUIM_List_Clear);
  1800.  
  1801.         set(obj,MUIA_List_Quiet,TRUE);
  1802.  
  1803.         while (desc = MUIS_ReadPubFile(pfh))
  1804.         {
  1805.             DoMethod(obj,MUIM_List_InsertSingle,desc,MUIV_List_Insert_Sorted);
  1806.         }
  1807.  
  1808.         set(obj,MUIA_List_Quiet,FALSE);
  1809.  
  1810.         MUIS_ClosePubFile(pfh);
  1811.     }
  1812.     return(result);
  1813. }
  1814.  
  1815.  
  1816. ULONG ScreenList_Save(struct IClass *cl,Object *obj,struct MUIP_ScreenList_Save *msg)
  1817. {
  1818.     ULONG result = FALSE;
  1819.     struct MUI_PubScreenDesc *desc;
  1820.     APTR pfh;
  1821.     int i;
  1822.  
  1823.     DoMethod(obj,MUIM_List_Sort);
  1824.  
  1825.     if (pfh = MUIS_OpenPubFile(msg->name,MODE_NEWFILE))
  1826.     {
  1827.         result = TRUE;
  1828.  
  1829.         for (i=0;result;i++)
  1830.         {
  1831.             DoMethod(obj,MUIM_List_GetEntry,i,&desc);
  1832.             if (!desc) break;
  1833.  
  1834.             desc->Changed  = FALSE;
  1835.             desc->UserData = NULL;
  1836.  
  1837.             if (!MUIS_WritePubFile(pfh,desc))
  1838.                 result = FALSE;
  1839.         }
  1840.         MUIS_ClosePubFile(pfh);
  1841.     }
  1842.     return(result);
  1843. }
  1844.  
  1845.  
  1846. ULONG ScreenList_Find(struct IClass *cl,Object *obj,struct MUIP_ScreenList_Find *msg)
  1847. {
  1848.     int i;
  1849.     struct MUI_PubScreenDesc *desc;
  1850.  
  1851.     *(msg->desc) = NULL;
  1852.  
  1853.     for (i=0;;i++)
  1854.     {
  1855.         DoMethod(obj,MUIM_List_GetEntry,i,&desc);
  1856.         if (!desc) break;
  1857.         if (!stricmp(desc->Name,msg->name))
  1858.         {
  1859.             *(msg->desc) = desc;
  1860.             set(obj,MUIA_List_Active,i);
  1861.             break;
  1862.         }
  1863.     }
  1864.     return(0);
  1865. }
  1866.  
  1867.  
  1868. static Object *makescreenimage(UBYTE *body)
  1869. {
  1870.     Object *obj = BodychunkObject,
  1871.         MUIA_FixWidth             , PSI_SCREENON_WIDTH ,
  1872.         MUIA_FixHeight            , PSI_SCREENON_HEIGHT,
  1873.         MUIA_Bitmap_Width         , PSI_SCREENON_WIDTH ,
  1874.         MUIA_Bitmap_Height        , PSI_SCREENON_HEIGHT,
  1875.         MUIA_Bodychunk_Depth      , PSI_SCREENON_DEPTH ,
  1876.         MUIA_Bodychunk_Body       , (UBYTE *)body,
  1877.         MUIA_Bodychunk_Compression, PSI_SCREENON_COMPRESSION,
  1878.         MUIA_Bodychunk_Masking    , PSI_SCREENON_MASKING,
  1879.         MUIA_Bitmap_SourceColors  , (ULONG *)psi_screenon_colors,
  1880.         MUIA_Bitmap_Transparent   , 0,
  1881.         End;
  1882.  
  1883.     return(obj);
  1884. }
  1885.  
  1886.  
  1887. ULONG ScreenList_Setup(struct IClass *cl,Object *obj,Msg msg)
  1888. {
  1889.     struct ScreenList_Data *data = INST_DATA(cl,obj);
  1890.  
  1891.     if (!DoSuperMethodA(cl,obj,msg))
  1892.         return(FALSE);
  1893.  
  1894.     data->onormal[0]  = makescreenimage((UBYTE *)psi_screencn_body);
  1895.     data->onormal[1]  = makescreenimage((UBYTE *)psi_screenon_body);
  1896.     /*
  1897.     data->oforeign[0] = makescreenimage((UBYTE *)psi_screencf_body);
  1898.     data->oforeign[1] = makescreenimage((UBYTE *)psi_screenof_body);
  1899.     */
  1900.  
  1901.     data->inormal[0]  = (APTR)DoMethod(obj,MUIM_List_CreateImage,data->onormal[0] ,0);
  1902.     data->inormal[1]  = (APTR)DoMethod(obj,MUIM_List_CreateImage,data->onormal[1] ,0);
  1903.     /*
  1904.     data->iforeign[0] = (APTR)DoMethod(obj,MUIM_List_CreateImage,data->oforeign[0],0);
  1905.     data->iforeign[1] = (APTR)DoMethod(obj,MUIM_List_CreateImage,data->oforeign[1],0);
  1906.     */
  1907.  
  1908.     MUI_RequestIDCMP(obj,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY);
  1909.  
  1910.     return(TRUE);
  1911. }
  1912.  
  1913.  
  1914. ULONG ScreenList_Cleanup(struct IClass *cl,Object *obj,Msg msg)
  1915. {
  1916.     struct ScreenList_Data *data = INST_DATA(cl,obj);
  1917.  
  1918.     DoMethod(obj,MUIM_List_DeleteImage,data->inormal[0] );
  1919.     DoMethod(obj,MUIM_List_DeleteImage,data->inormal[1] );
  1920.     /*
  1921.     DoMethod(obj,MUIM_List_DeleteImage,data->iforeign[0]);
  1922.     DoMethod(obj,MUIM_List_DeleteImage,data->iforeign[1]);
  1923.     */
  1924.  
  1925.     if (data->onormal[0] ) MUI_DisposeObject(data->onormal[0] );
  1926.     if (data->onormal[1] ) MUI_DisposeObject(data->onormal[1] );
  1927.     /*
  1928.     if (data->oforeign[0]) MUI_DisposeObject(data->oforeign[0]);
  1929.     if (data->oforeign[1]) MUI_DisposeObject(data->oforeign[1]);
  1930.     */
  1931.  
  1932.     MUI_RejectIDCMP(obj,IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY);
  1933.  
  1934.     return(DoSuperMethodA(cl,obj,msg));
  1935. }
  1936.  
  1937.  
  1938. ULONG ScreenList_New(struct IClass *cl,Object *obj,struct opSet *msg)
  1939. {
  1940.     static const struct Hook ScreenList_ConstructHook = { { 0,0 }, (VOID *)ScreenList_ConstructFunc, NULL, NULL };
  1941.     static const struct Hook ScreenList_DestructHook  = { { 0,0 }, (VOID *)ScreenList_DestructFunc , NULL, NULL };
  1942.     static const struct Hook ScreenList_CompareHook   = { { 0,0 }, (VOID *)ScreenList_CompareFunc  , NULL, NULL };
  1943.  
  1944.     obj=(Object *)DoSuperNew(cl,obj,
  1945.         MUIA_List_ConstructHook, &ScreenList_ConstructHook,
  1946.         MUIA_List_DestructHook , &ScreenList_DestructHook,
  1947.         MUIA_List_CompareHook  , &ScreenList_CompareHook,
  1948.         MUIA_List_Format       , "DELTA=2,,,",
  1949.         MUIA_List_Title        , TRUE,
  1950.         MUIA_List_MinLineHeight, 14,
  1951.         TAG_MORE,msg->ops_AttrList);
  1952.  
  1953.     if (obj)
  1954.     {
  1955.         struct ScreenList_Data *data = INST_DATA(cl,obj);
  1956.  
  1957.         data->DisplayHook.h_Entry = (VOID *)ScreenList_DisplayFunc;
  1958.         data->DisplayHook.h_Data  = (APTR)data;
  1959.  
  1960.         set(obj,MUIA_List_DisplayHook,&data->DisplayHook);
  1961.     }
  1962.  
  1963.     return((ULONG)obj);
  1964. }
  1965.  
  1966. SAVEDS ASM ULONG ScreenList_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  1967. {
  1968.     switch (msg->MethodID)
  1969.     {
  1970.         case OM_NEW              : return(ScreenList_New    (cl,obj,(APTR)msg));
  1971.         case MUIM_Setup          : return(ScreenList_Setup  (cl,obj,(APTR)msg));
  1972.         case MUIM_Cleanup        : return(ScreenList_Cleanup(cl,obj,(APTR)msg));
  1973.         case MUIM_ScreenList_Save: return(ScreenList_Save   (cl,obj,(APTR)msg));
  1974.         case MUIM_ScreenList_Load: return(ScreenList_Load   (cl,obj,(APTR)msg));
  1975.         case MUIM_ScreenList_Find: return(ScreenList_Find   (cl,obj,(APTR)msg));
  1976.     }
  1977.     return(DoSuperMethodA(cl,obj,msg));
  1978. }
  1979.  
  1980.  
  1981.  
  1982. /****************************************************************************/
  1983. /* ScreenPanel class                                                        */
  1984. /****************************************************************************/
  1985.  
  1986. struct ScreenPanel_Data
  1987. {
  1988.     Object *LV_Screens;
  1989.     Object *BT_Create;
  1990.     Object *BT_Copy;
  1991.     Object *BT_Delete;
  1992.     Object *BT_Edit;
  1993.     Object *BT_Open;
  1994.     Object *BT_Close;
  1995.     Object *BT_Jump;
  1996.     #ifdef MYDEBUG
  1997.     Object *BT_Foo;
  1998.     #endif
  1999. };
  2000.  
  2001. ULONG ScreenPanel_Finish(struct IClass *cl,Object *obj,struct MUIP_ScreenPanel_Finish *msg)
  2002. {
  2003.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2004.     struct MUI_PubScreenDesc *desc;
  2005.     int i;
  2006.     Object *win = msg->win;
  2007.     BOOL ok = msg->ok;
  2008.  
  2009.     for (i=0;;i++)
  2010.     {
  2011.         DoMethod(data->LV_Screens,MUIM_List_GetEntry,i,&desc);
  2012.         if (!desc) return(0); /* should never happen */
  2013.         if (desc->UserData==win) break;
  2014.     }
  2015.  
  2016.     desc->UserData = NULL;
  2017.  
  2018.     if (ok)
  2019.     {
  2020.         DoMethod(win,MUIM_EditPanel_GetScreen,desc);
  2021.         desc->Changed = TRUE;
  2022.     }
  2023.     DoMethod(data->LV_Screens,MUIM_List_Redraw,i);
  2024.     DoMethod(obj,MUIM_ScreenPanel_SetStates);
  2025.  
  2026.     set(win,MUIA_Window_Open,FALSE);
  2027.     DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,win);
  2028.     MUI_DisposeObject(win);
  2029.  
  2030.     return(0);
  2031. }
  2032.  
  2033. ULONG ScreenPanel_Edit(struct IClass *cl,Object *obj,Msg msg)
  2034. {
  2035.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2036.     struct MUI_PubScreenDesc *desc;
  2037.  
  2038.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  2039.  
  2040.     if (desc)
  2041.     {
  2042.         set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,TRUE);
  2043.  
  2044.         if (!desc->UserData)
  2045.         {
  2046.             if (desc->UserData = (APTR)NewObject(CL_EditWindow->mcc_Class,NULL,
  2047.                 MUIA_Window_Width , MUIV_Window_Width_MinMax(0),
  2048.                 MUIA_Window_Height, MUIV_Window_Height_MinMax(0),
  2049.                 MUIA_EditWindow_Title, desc->Name,
  2050.                 MUIA_EditWindow_Originator, obj,
  2051.                 TAG_DONE))
  2052.             {
  2053.                 DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_ADDMEMBER,desc->UserData);
  2054.                 DoMethod(desc->UserData,MUIM_EditPanel_SetScreen,desc);
  2055.                 DoMethod(data->LV_Screens,MUIM_List_Redraw,MUIV_List_Redraw_Active);
  2056.             }
  2057.         }
  2058.  
  2059.         if (desc->UserData)
  2060.             set(desc->UserData,MUIA_Window_Open,TRUE);
  2061.         else
  2062.             DisplayBeep(0);
  2063.  
  2064.         set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,FALSE);
  2065.     }
  2066.     return(0);
  2067. }
  2068.  
  2069. ULONG ScreenPanel_Delete(struct IClass *cl,Object *obj,Msg msg)
  2070. {
  2071.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2072.     struct MUI_PubScreenDesc *desc;
  2073.  
  2074.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  2075.     if (desc)
  2076.     {
  2077.         if (!desc->UserData)
  2078.         {
  2079.             MUIS_ClosePubScreen(desc->Name);
  2080.             DoMethod(data->LV_Screens,MUIM_List_Remove,MUIV_List_Remove_Active);
  2081.         }
  2082.         else
  2083.             DisplayBeep(0);
  2084.     }
  2085.     return(0);
  2086. }
  2087.  
  2088. ULONG ScreenPanel_Create(struct IClass *cl,Object *obj,Msg msg)
  2089. {
  2090.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2091.     DoMethod(data->LV_Screens,MUIM_List_InsertSingle,NULL,MUIV_List_Insert_Bottom);
  2092.     set(data->LV_Screens,MUIA_List_Active,MUIV_List_Active_Bottom);
  2093.     return(0);
  2094. }
  2095.  
  2096. ULONG ScreenPanel_Copy(struct IClass *cl,Object *obj,Msg msg)
  2097. {
  2098.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2099.     struct MUI_PubScreenDesc *new,*src;
  2100.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&src);
  2101.     if (new = MUIS_AllocPubScreenDesc(src))
  2102.     {
  2103.         char namebuf[PSD_MAXLEN_NAME];
  2104.         strcpy(namebuf,new->Name);
  2105.         strcpy(new->Name,">");
  2106.         stccpy(new->Name+1,namebuf,PSD_MAXLEN_NAME-1);
  2107.         DoMethod(data->LV_Screens,MUIM_List_InsertSingle,new,MUIV_List_Insert_Bottom);
  2108.         set(data->LV_Screens,MUIA_List_Active,MUIV_List_Active_Bottom);
  2109.         MUIS_FreePubScreenDesc(new);
  2110.     }
  2111.     else
  2112.         DisplayBeep(0);
  2113.     return(0);
  2114. }
  2115.  
  2116. ULONG ScreenPanel_SetStates(struct IClass *cl,Object *obj,Msg msg)
  2117. {
  2118.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2119.     struct MUI_PubScreenDesc *desc;
  2120.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  2121.     if (desc)
  2122.     {
  2123.         /*
  2124.         if (desc->Foreign)
  2125.         {
  2126.             set(data->BT_Copy  ,MUIA_Disabled,FALSE);
  2127.             set(data->BT_Delete,MUIA_Disabled,FALSE);
  2128.             set(data->BT_Edit  ,MUIA_Disabled,FALSE);
  2129.             set(data->BT_Open  ,MUIA_Disabled,TRUE );
  2130.             set(data->BT_Close ,MUIA_Disabled,TRUE );
  2131.             set(data->BT_Jump  ,MUIA_Disabled,FALSE);
  2132.         }
  2133.         else
  2134.         */
  2135.         {
  2136.             BOOL opened = TestPubScreen(desc->Name);
  2137.  
  2138.             set(data->BT_Copy  ,MUIA_Disabled,FALSE);
  2139.             set(data->BT_Delete,MUIA_Disabled,FALSE);
  2140.             set(data->BT_Edit  ,MUIA_Disabled,FALSE);
  2141.             set(data->BT_Open  ,MUIA_Disabled, opened);
  2142.             set(data->BT_Close ,MUIA_Disabled,!opened);
  2143.             set(data->BT_Jump  ,MUIA_Disabled,FALSE);
  2144.         }
  2145.     }
  2146.     else
  2147.     {
  2148.         set(data->BT_Copy  ,MUIA_Disabled,TRUE);
  2149.         set(data->BT_Delete,MUIA_Disabled,TRUE);
  2150.         set(data->BT_Edit  ,MUIA_Disabled,TRUE);
  2151.         set(data->BT_Open  ,MUIA_Disabled,TRUE);
  2152.         set(data->BT_Close ,MUIA_Disabled,TRUE);
  2153.         set(data->BT_Jump  ,MUIA_Disabled,TRUE);
  2154.     }
  2155.     return(0);
  2156. }
  2157.  
  2158. ULONG ScreenPanel_Close(struct IClass *cl,Object *obj,Msg msg)
  2159. {
  2160.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2161.     struct MUI_PubScreenDesc *desc;
  2162.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  2163.     if (!desc || !MUIS_ClosePubScreen(desc->Name))
  2164.         DisplayBeep(0);
  2165.     return(0);
  2166. }
  2167.  
  2168. ULONG ScreenPanel_Open(struct IClass *cl,Object *obj,Msg msg)
  2169. {
  2170.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2171.     struct MUI_PubScreenDesc *desc;
  2172.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  2173.    if (desc)
  2174.     {
  2175.         if (desc->Changed)
  2176.         {
  2177.             /* !!! */
  2178.         }
  2179.         if (!MUIS_OpenPubScreen(desc))
  2180.             DisplayBeep(0);
  2181.     }
  2182.     else
  2183.         DisplayBeep(0);
  2184.     return(0);
  2185. }
  2186.  
  2187. ULONG ScreenPanel_Jump(struct IClass *cl,Object *obj,Msg msg)
  2188. {
  2189.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2190.     struct MUI_PubScreenDesc *desc;
  2191.     DoMethod(data->LV_Screens,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  2192.     if (desc)
  2193.     {
  2194.         if (desc->Changed)
  2195.         {
  2196.             /* !!! */
  2197.         }
  2198.         DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_SetConfigItem,MUICFG_PublicScreen,desc->Name);
  2199.     }
  2200.     else
  2201.         DisplayBeep(0);
  2202.  
  2203.     return(0);
  2204. }
  2205.  
  2206. ULONG ScreenPanel_Update(struct IClass *cl,Object *obj,Msg msg)
  2207. {
  2208.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2209.     DoMethod(data->LV_Screens,MUIM_List_Redraw,MUIV_List_Redraw_All);
  2210.     DoMethod(obj,MUIM_ScreenPanel_SetStates);
  2211.     return(0);
  2212. }
  2213.  
  2214. ULONG ScreenPanel_New(struct IClass *cl,Object *obj,struct opSet *msg)
  2215. {
  2216.     struct ScreenPanel_Data tmp = {0};
  2217.  
  2218.     obj = (Object *)DoSuperNew(cl,obj,
  2219.         MUIA_Group_Horiz, FALSE,
  2220.         MUIA_Group_VertSpacing, 0,
  2221.         Child, tmp.LV_Screens = ListviewObject,
  2222.             MUIA_CycleChain, 1,
  2223.             MUIA_Listview_List, NewObject(CL_ScreenList->mcc_Class,NULL,InputListFrame,MUIA_List_AutoVisible,TRUE,TAG_DONE),
  2224.             End,
  2225.         Child, ColGroup(4), GroupSpacing(0), MUIA_Group_SameSize, TRUE,
  2226.             Child, tmp.BT_Create = MakeButton(MSG_BUTTON_NEW),
  2227.             Child, tmp.BT_Copy   = MakeButton(MSG_BUTTON_COPY),
  2228.             Child, tmp.BT_Delete = MakeButton(MSG_BUTTON_DELETE),
  2229.             Child, tmp.BT_Edit   = MakeButton(MSG_BUTTON_EDIT),
  2230.             Child, tmp.BT_Open   = MakeButton(MSG_BUTTON_OPEN),
  2231.             Child, tmp.BT_Close  = MakeButton(MSG_BUTTON_CLOSE),
  2232.             Child, tmp.BT_Jump   = MakeButton(MSG_BUTTON_JUMP),
  2233.             #ifdef MYDEBUG
  2234.             Child, tmp.BT_Foo    = SimpleButton("Foo"),
  2235.             #else
  2236.             Child, HVSpace,
  2237.             #endif
  2238.             End,
  2239.         TAG_DONE);
  2240.  
  2241.     if (obj)
  2242.     {
  2243.         struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2244.  
  2245.         *data = tmp;
  2246.  
  2247.         DoMethod(tmp.BT_Delete ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Delete);
  2248.         DoMethod(tmp.BT_Create ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Create);
  2249.         DoMethod(tmp.BT_Copy   ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Copy  );
  2250.         DoMethod(tmp.BT_Edit   ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Edit  );
  2251.         DoMethod(tmp.BT_Open   ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Open  );
  2252.         DoMethod(tmp.BT_Close  ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Close );
  2253.         DoMethod(tmp.BT_Jump   ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Jump  );
  2254.         #ifdef MYDEBUG
  2255.         DoMethod(tmp.BT_Foo    ,MUIM_Notify,MUIA_Pressed,FALSE,obj,1,MUIM_ScreenPanel_Foo   );
  2256.         #endif
  2257.         DoMethod(tmp.LV_Screens,MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,obj,1,MUIM_ScreenPanel_Edit);
  2258.         DoMethod(tmp.LV_Screens,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,obj,1,MUIM_ScreenPanel_SetStates);
  2259.  
  2260.         set(tmp.BT_Delete ,MUIA_ShortHelp,GetStr(MSG_HELP_DELETESCREEN));
  2261.         set(tmp.BT_Create ,MUIA_ShortHelp,GetStr(MSG_HELP_NEWSCREEN   ));
  2262.         set(tmp.BT_Copy   ,MUIA_ShortHelp,GetStr(MSG_HELP_COPYSCREEN  ));
  2263.         set(tmp.BT_Edit   ,MUIA_ShortHelp,GetStr(MSG_HELP_EDITSCREEN  ));
  2264.         set(tmp.BT_Open   ,MUIA_ShortHelp,GetStr(MSG_HELP_OPENSCREEN  ));
  2265.         set(tmp.BT_Close  ,MUIA_ShortHelp,GetStr(MSG_HELP_CLOSESCREEN ));
  2266.         set(tmp.BT_Jump   ,MUIA_ShortHelp,GetStr(MSG_HELP_JUMPSCREEN  ));
  2267.         set(tmp.LV_Screens,MUIA_ShortHelp,GetStr(MSG_HELP_SCREENLIST  ));
  2268.  
  2269.         DoMethod(obj,MUIM_ScreenPanel_SetStates);
  2270.     }
  2271.     return((ULONG)obj);
  2272. }
  2273.  
  2274. ULONG ScreenPanel_Dispose(struct IClass *cl,Object *obj,Msg msg)
  2275. {
  2276.     DoMethod(obj,MUIM_ScreenPanel_CloseWindows);
  2277.     return(DoSuperMethodA(cl,obj,msg));
  2278. }
  2279.  
  2280. ULONG ScreenPanel_CloseWindows(struct IClass *cl,Object *obj,Msg msg)
  2281. {
  2282.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2283.     struct MUI_PubScreenDesc *desc;
  2284.     int i;
  2285.     for (i=0;;i++)
  2286.     {
  2287.         DoMethod(data->LV_Screens,MUIM_List_GetEntry,i,&desc);
  2288.         if (!desc) break;
  2289.         if (desc->UserData) DoMethod(obj,MUIM_ScreenPanel_Finish,desc->UserData,FALSE);
  2290.     }
  2291.     return(0);
  2292. }
  2293.  
  2294. #ifdef MYDEBUG
  2295.  
  2296. BOOL SavePubScreen(struct MUI_PubScreenDesc *desc)
  2297. {
  2298.     BPTR file;
  2299.     char filename[PSD_MAXLEN_NAME+16];
  2300.     int p;
  2301.     BOOL rc = FALSE;
  2302.  
  2303.     strcpy(filename,"mui:Screens");
  2304.     AddPart(filename,desc->Name,sizeof(filename));
  2305.     strcat(filename,".mps");
  2306.  
  2307.     if (file = Open(filename,MODE_NEWFILE))
  2308.     {
  2309.         FPrintf(file,"T=\"%s\"\n",desc->Title       );
  2310.         FPrintf(file,"F=\"%s\"\n",desc->Font        );
  2311.         FPrintf(file,"B=\"%s\"\n",desc->Background  );
  2312.         FPrintf(file,"W=%ld\n"   ,desc->DisplayWidth);
  2313.         FPrintf(file,"H=%ld\n"   ,desc->DisplayHeight);
  2314.         FPrintf(file,"D=%ld\n"   ,desc->DisplayDepth);
  2315.         FPrintf(file,"I=%ld\n"   ,desc->DisplayID   );
  2316.         if (desc->OverscanType) FPrintf(file,"OS\n");
  2317.         if (desc->AutoScroll  ) FPrintf(file,"AS\n");
  2318.         if (desc->NoDrag      ) FPrintf(file,"ND\n");
  2319.         if (desc->Exclusive   ) FPrintf(file,"EX\n");
  2320.         if (desc->Interleaved ) FPrintf(file,"IN\n");
  2321.         if (desc->SysDefault  ) FPrintf(file,"SD\n");
  2322.         if (desc->Behind      ) FPrintf(file,"BH\n");
  2323.         if (desc->AutoClose   ) FPrintf(file,"AC\n");
  2324.         if (desc->CloseGadget ) FPrintf(file,"CG\n");
  2325.  
  2326.         FPrintf(file,"PEN=\"");
  2327.         for (p=0;p<PSD_NUMSYSPENS;p++)
  2328.             FPrintf(file,"%ld:%ld ",p,desc->SystemPens[p]);
  2329.         FPrintf(file,"\"\n");
  2330.  
  2331.         FPrintf(file,"PAL=\"");
  2332.         for (p=0;p<PSD_NUMCOLS;p++)
  2333.             FPrintf(file,"%ld:%02lx%02lx%02lx ",p<4 ? p : p-8,desc->Palette[p].red>>24,desc->Palette[p].green>>24,desc->Palette[p].blue>>24);
  2334.         FPrintf(file,"\"\n");
  2335.  
  2336.         rc = TRUE;
  2337.  
  2338.         Close(file);
  2339.     }
  2340.     return(rc);
  2341. }
  2342.  
  2343.  
  2344. ULONG ScreenPanel_Foo(struct IClass *cl,Object *obj,Msg msg)
  2345. {
  2346.     struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2347.     struct MUI_PubScreenDesc *desc;
  2348.     int i;
  2349.  
  2350.     for (i=0;;i++)
  2351.     {
  2352.         int p;
  2353.  
  2354.         DoMethod(data->LV_Screens,MUIM_List_GetEntry,i,&desc);
  2355.         if (!desc) break;
  2356.  
  2357.         printf("N=\"%s\"\n",desc->Name        );
  2358.         printf("T=\"%s\"\n",desc->Title       );
  2359.         printf("F=\"%s\"\n",desc->Font        );
  2360.         printf("B=\"%s\"\n",desc->Background  );
  2361.         printf("W=%ld\n"   ,desc->DisplayWidth);
  2362.         printf("H=%ld\n"   ,desc->DisplayHeight);
  2363.         printf("D=%ld\n"   ,desc->DisplayDepth);
  2364.         printf("I=%ld\n"   ,desc->DisplayID   );
  2365.         if (desc->OverscanType) printf("OS\n");
  2366.         if (desc->AutoScroll  ) printf("AS\n");
  2367.         if (desc->NoDrag      ) printf("ND\n");
  2368.         if (desc->Exclusive   ) printf("EX\n");
  2369.         if (desc->Interleaved ) printf("IN\n");
  2370.         if (desc->SysDefault  ) printf("SD\n");
  2371.         if (desc->Behind      ) printf("BH\n");
  2372.         if (desc->AutoClose   ) printf("AC\n");
  2373.         if (desc->CloseGadget ) printf("CG\n");
  2374.  
  2375.         printf("PENS=\"");
  2376.         for (p=0;p<PSD_NUMSYSPENS;p++)
  2377.             printf("%ld:%ld ",p,desc->SystemPens[p]);
  2378.         printf("\"\n");
  2379.  
  2380.         printf("PALETTE=\"");
  2381.         for (p=0;p<PSD_NUMCOLS;p++)
  2382.             printf("%ld:%02lx%02lx%02lx ",p<4 ? p : p-8,desc->Palette[p].red>>24,desc->Palette[p].green>>24,desc->Palette[p].blue>>24);
  2383.         printf("\"\n");
  2384.  
  2385.         printf("\n");
  2386.  
  2387.         /*
  2388.         if (!desc->Foreign)
  2389.         */
  2390.             SavePubScreen(desc);
  2391.     }
  2392.     return(0);
  2393. }
  2394. #endif
  2395.  
  2396. SAVEDS ASM ULONG ScreenPanel_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  2397. {
  2398.     switch (msg->MethodID)
  2399.     {
  2400.         case OM_NEW                       : return(ScreenPanel_New         (cl,obj,(APTR)msg));
  2401.         case OM_DISPOSE                   : return(ScreenPanel_Dispose     (cl,obj,(APTR)msg));
  2402.         case MUIM_ScreenPanel_Create      : return(ScreenPanel_Create      (cl,obj,(APTR)msg));
  2403.         case MUIM_ScreenPanel_Copy        : return(ScreenPanel_Copy        (cl,obj,(APTR)msg));
  2404.         case MUIM_ScreenPanel_Delete      : return(ScreenPanel_Delete      (cl,obj,(APTR)msg));
  2405.         case MUIM_ScreenPanel_Edit        : return(ScreenPanel_Edit        (cl,obj,(APTR)msg));
  2406.         case MUIM_ScreenPanel_Finish      : return(ScreenPanel_Finish      (cl,obj,(APTR)msg));
  2407.         case MUIM_ScreenPanel_CloseWindows: return(ScreenPanel_CloseWindows(cl,obj,(APTR)msg));
  2408.         case MUIM_ScreenPanel_SetStates   : return(ScreenPanel_SetStates   (cl,obj,(APTR)msg));
  2409.         case MUIM_ScreenPanel_Open        : return(ScreenPanel_Open        (cl,obj,(APTR)msg));
  2410.         case MUIM_ScreenPanel_Close       : return(ScreenPanel_Close       (cl,obj,(APTR)msg));
  2411.         case MUIM_ScreenPanel_Jump        : return(ScreenPanel_Jump        (cl,obj,(APTR)msg));
  2412.         case MUIM_ScreenPanel_Update      : return(ScreenPanel_Update      (cl,obj,(APTR)msg));
  2413.         #ifdef MYDEBUG
  2414.         case MUIM_ScreenPanel_Foo         : return(ScreenPanel_Foo         (cl,obj,(APTR)msg));
  2415.         #endif
  2416.  
  2417.         case MUIM_ScreenList_Find:
  2418.         {
  2419.             struct ScreenPanel_Data *data = INST_DATA(cl,obj);
  2420.             return(DoMethodA(data->LV_Screens,msg));
  2421.         }
  2422.     }
  2423.     return(DoSuperMethodA(cl,obj,msg));
  2424. }
  2425.  
  2426.  
  2427.  
  2428. /****************************************************************************/
  2429. /* MainWindow class                                                         */
  2430. /****************************************************************************/
  2431.  
  2432. struct MainWindow_Data
  2433. {
  2434.     Object *PA_Screens;
  2435. };
  2436.  
  2437.  
  2438. ULONG MainWindow_Finish(struct IClass *cl,Object *obj,struct MUIP_MainWindow_Finish *msg)
  2439. {
  2440.     struct MainWindow_Data *data = INST_DATA(cl,obj);
  2441.     if (msg->level>=1) DoMethod(data->PA_Screens,MUIM_ScreenList_Save,PSD_FILENAME_USE );
  2442.     if (msg->level>=2) DoMethod(data->PA_Screens,MUIM_ScreenList_Save,PSD_FILENAME_SAVE);
  2443.     DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  2444.  
  2445.     return(0);
  2446. }
  2447.  
  2448. ULONG MainWindow_About(struct IClass *cl,Object *obj,Msg msg)
  2449. {
  2450.     struct MainWindow_Data *data = INST_DATA(cl,obj);
  2451.     Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
  2452.     static const char AboutText[] = "\33b\33cPSI - Public Screen Inspector\33n\n\33cVersion: %s\n\33c%s\n\n\33c%s %ld\n\33cARexx-Port: %s";
  2453.     MUI_Request(app,obj,0,NULL,GetStr(MSG_BUTTON_OK),(char *)AboutText,
  2454.         ((char *)xget(app,MUIA_Application_Version))+10,
  2455.         ((char *)xget(app,MUIA_Application_Copyright)),
  2456.         GetStr(MSG_ABOUT_NUMBEROFSCREENS),
  2457.         xget(data->PA_Screens,MUIA_List_Entries),
  2458.         ((char *)xget(app,MUIA_Application_Base)));
  2459.     return(0);
  2460. }
  2461.  
  2462. SAVEDS ASM VOID IntuiMsgFunc(REG(a1) struct IntuiMessage *imsg,REG(a2) struct FileRequester *req)
  2463. {
  2464.     if (imsg->Class==IDCMP_REFRESHWINDOW)
  2465.         DoMethod(req->fr_UserData,MUIM_Application_CheckRefresh);
  2466. }
  2467.  
  2468. char *getfilename(Object *win,char *title,BOOL save)
  2469. {
  2470.     static char buf[512];
  2471.     struct FileRequester *req;
  2472.     struct Window *w;
  2473.     static LONG left=-1,top=-1,width=-1,height=-1;
  2474.     Object *app = (Object *)xget(win,MUIA_ApplicationObject);
  2475.     char *res = NULL;
  2476.     static const struct Hook IntuiMsgHook = { { 0,0 },(VOID *)IntuiMsgFunc,NULL,NULL };
  2477.  
  2478.     get(win,MUIA_Window_Window,&w);
  2479.     if (left==-1)
  2480.     {
  2481.         left   = w->LeftEdge+w->BorderLeft+2;
  2482.         top    = w->TopEdge+w->BorderTop+2;
  2483.         width  = w->Width-w->BorderLeft-w->BorderRight-4;
  2484.         height = w->Height-w->BorderTop-w->BorderBottom-4;
  2485.     }
  2486.  
  2487.     if (req=MUI_AllocAslRequestTags(ASL_FileRequest,
  2488.         ASLFR_Window, w,
  2489.         ASLFR_TitleText, title,
  2490.         ASLFR_InitialLeftEdge, left,
  2491.         ASLFR_InitialTopEdge , top,
  2492.         ASLFR_InitialWidth   , width,
  2493.         ASLFR_InitialHeight  , height,
  2494.         ASLFR_InitialDrawer  , "envarc:mui",
  2495.         ASLFR_InitialPattern , "#?.iff",
  2496.         ASLFR_DoSaveMode     , save,
  2497.         ASLFR_DoPatterns     , TRUE,
  2498.         ASLFR_RejectIcons    , TRUE,
  2499.         ASLFR_UserData       , app,
  2500.         ASLFR_IntuiMsgFunc   , &IntuiMsgHook,
  2501.         TAG_DONE))
  2502.     {
  2503.         set(app,MUIA_Application_Sleep,TRUE);
  2504.         if (MUI_AslRequestTags(req,TAG_DONE))
  2505.         {
  2506.             if (*req->fr_File)
  2507.             {
  2508.                 res = buf;
  2509.                 stccpy(buf,req->fr_Drawer,sizeof(buf));
  2510.                 AddPart(buf,req->fr_File,sizeof(buf));
  2511.             }
  2512.             left   = req->fr_LeftEdge;
  2513.             top    = req->fr_TopEdge;
  2514.             width  = req->fr_Width;
  2515.             height = req->fr_Height;
  2516.         }
  2517.         MUI_FreeAslRequest(req);
  2518.         set(app,MUIA_Application_Sleep,FALSE);
  2519.     }
  2520.     return(res);
  2521. }
  2522.  
  2523. ULONG MainWindow_Open(struct IClass *cl,Object *obj,struct MUIP_MainWindow_Open *msg)
  2524. {
  2525.     struct MainWindow_Data *data = INST_DATA(cl,obj);
  2526.     char *title = msg->append ? GetStr(MSG_TITLE_APPEND) : GetStr(MSG_TITLE_OPEN);
  2527.     char *name;
  2528.     if ((name=getfilename(obj,title,FALSE)) && *name)
  2529.     {
  2530.         if (!msg->append) DoMethod(data->PA_Screens,MUIM_ScreenPanel_CloseWindows);
  2531.         DoMethod(data->PA_Screens,MUIM_ScreenList_Load,name,msg->append ? FALSE : TRUE);
  2532.     }
  2533.     return(0);
  2534. }
  2535.  
  2536. ULONG MainWindow_SaveAs(struct IClass *cl,Object *obj,Msg msg)
  2537. {
  2538.     struct MainWindow_Data *data = INST_DATA(cl,obj);
  2539.     char *title = GetStr(MSG_TITLE_SAVE);
  2540.     char *name;
  2541.     if ((name=getfilename(obj,title,TRUE)) && *name)
  2542.     {
  2543.         DoMethod(data->PA_Screens,MUIM_ScreenList_Save,name);
  2544.     }
  2545.     return(0);
  2546. }
  2547.  
  2548. ULONG MainWindow_Restore(struct IClass *cl,Object *obj,struct MUIP_MainWindow_Restore *msg)
  2549. {
  2550.     struct MainWindow_Data *data = INST_DATA(cl,obj);
  2551.     DoMethod(data->PA_Screens,MUIM_ScreenPanel_CloseWindows);
  2552.     DoMethod(data->PA_Screens,MUIM_ScreenList_Load,msg->envarc ? PSD_FILENAME_SAVE : PSD_FILENAME_USE,TRUE);
  2553.     return(0);
  2554. }
  2555.  
  2556. ULONG MainWindow_New(struct IClass *cl,Object *obj,struct opSet *msg)
  2557. {
  2558.     Object *BT_Save;
  2559.     Object *BT_Use;
  2560.     Object *BT_Cancel;
  2561.     Object *PA_Screens;
  2562.     Object *strip;
  2563.  
  2564.     if (obj = (Object *)DoSuperNew(cl,obj,
  2565.             MUIA_Window_Title, "PSI - Public Screen Inspector",
  2566.             MUIA_Window_ID   , MAKE_ID('M','A','I','N'),
  2567.             MUIA_Window_Menustrip, strip = MUI_MakeObject(MUIO_MenustripNM,MainMenu,0),
  2568.             WindowContents, VGroup,
  2569.                 Child, PA_Screens = NewObject(CL_ScreenPanel->mcc_Class,NULL,TAG_DONE),
  2570.                 Child, MUI_MakeObject(MUIO_HBar,2),
  2571.                 Child, HGroup, MUIA_Group_SameSize, TRUE,
  2572.                     Child, BT_Save = MakeButton(MSG_BUTTON_SAVE),
  2573.                     Child, HSpace(0),
  2574.                     Child, BT_Use = MakeButton(MSG_BUTTON_USE),
  2575.                     Child, HSpace(0),
  2576.                     Child, BT_Cancel = MakeButton(MSG_BUTTON_CANCEL),
  2577.                     End,
  2578.                 End,
  2579.             TAG_MORE,msg->ops_AttrList))
  2580.     {
  2581.         struct MainWindow_Data *data = INST_DATA(cl,obj);
  2582.  
  2583.         data->PA_Screens = PA_Screens;
  2584.  
  2585.         DoMethod(obj      ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE ,obj,2,MUIM_MainWindow_Finish,0);
  2586.         DoMethod(BT_Cancel,MUIM_Notify,MUIA_Pressed            ,FALSE,obj,2,MUIM_MainWindow_Finish,0);
  2587.         DoMethod(BT_Use   ,MUIM_Notify,MUIA_Pressed            ,FALSE,obj,2,MUIM_MainWindow_Finish,1);
  2588.         DoMethod(BT_Save  ,MUIM_Notify,MUIA_Pressed            ,FALSE,obj,2,MUIM_MainWindow_Finish,2);
  2589.  
  2590.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_ABOUT    ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,1,MUIM_MainWindow_About);
  2591.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_OPEN     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Open,0);
  2592.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_APPEND   ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Open,1);
  2593.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_SAVEAS   ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,1,MUIM_MainWindow_SaveAs);
  2594.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_QUIT     ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Finish,0);
  2595.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_LASTSAVED),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Restore,1);
  2596.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_RESTORE  ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Restore,0);
  2597.         DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_MUI      ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,MUIV_Notify_Application,2,MUIM_Application_OpenConfigWindow,0);
  2598.  
  2599.         DoMethod(PA_Screens,MUIM_ScreenList_Load,PSD_FILENAME_USE,TRUE);
  2600.  
  2601.         set(BT_Save  ,MUIA_ShortHelp,GetStr(MSG_HELP_SAVE  ));
  2602.         set(BT_Use   ,MUIA_ShortHelp,GetStr(MSG_HELP_USE   ));
  2603.         set(BT_Cancel,MUIA_ShortHelp,GetStr(MSG_HELP_CANCEL));
  2604.  
  2605.         return((ULONG)obj);
  2606.     }
  2607.     return(0);
  2608. }
  2609.  
  2610. SAVEDS ASM ULONG MainWindow_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  2611. {
  2612.     switch (msg->MethodID)
  2613.     {
  2614.         case OM_NEW                 : return(MainWindow_New    (cl,obj,(APTR)msg));
  2615.         case MUIM_MainWindow_Finish : return(MainWindow_Finish (cl,obj,(APTR)msg));
  2616.         case MUIM_MainWindow_About  : return(MainWindow_About  (cl,obj,(APTR)msg));
  2617.         case MUIM_MainWindow_Open   : return(MainWindow_Open   (cl,obj,(APTR)msg));
  2618.         case MUIM_MainWindow_SaveAs : return(MainWindow_SaveAs (cl,obj,(APTR)msg));
  2619.         case MUIM_MainWindow_Restore: return(MainWindow_Restore(cl,obj,(APTR)msg));
  2620.  
  2621.         case MUIM_ScreenPanel_CloseWindows:
  2622.         case MUIM_ScreenPanel_Update:
  2623.         case MUIM_ScreenList_Find:
  2624.         {
  2625.             struct MainWindow_Data *data = INST_DATA(cl,obj);
  2626.             return(DoMethodA(data->PA_Screens,msg));
  2627.         }
  2628.     }
  2629.     return(DoSuperMethodA(cl,obj,msg));
  2630. }
  2631.  
  2632.  
  2633.  
  2634. /****************************************************************************/
  2635. /* Init/Exit Functions                                                      */
  2636. /****************************************************************************/
  2637.  
  2638. VOID ExitLibs(VOID)
  2639. {
  2640.     if (IntuitionBase) CloseLibrary(IntuitionBase);
  2641.     if (GfxBase      ) CloseLibrary(GfxBase      );
  2642.     if (AslBase      ) CloseLibrary(AslBase      );
  2643.     if (UtilityBase  ) CloseLibrary(UtilityBase  );
  2644.     if (MUIScreenBase) CloseLibrary(MUIScreenBase);
  2645.     if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  2646. }
  2647.  
  2648. BOOL InitLibs(VOID)
  2649. {
  2650.     MUIMasterBase = OpenLibrary("muimaster.library",11);
  2651.     MUIScreenBase = OpenLibrary("muiscreen.library",11);
  2652.     UtilityBase   = OpenLibrary("utility.library"  ,36);
  2653.     AslBase       = OpenLibrary("asl.library"      ,36);
  2654.     GfxBase       = OpenLibrary("graphics.library" ,36);
  2655.     IntuitionBase = OpenLibrary("intuition.library",36);
  2656.  
  2657.     if (MUIMasterBase && MUIScreenBase && UtilityBase && AslBase && GfxBase && IntuitionBase)
  2658.         return(TRUE);
  2659.  
  2660.     ExitLibs();
  2661.     return(FALSE);
  2662. }
  2663.  
  2664. VOID ExitClasses(VOID)
  2665. {
  2666.     if (CL_MainWindow  ) MUI_DeleteCustomClass(CL_MainWindow  );
  2667.     if (CL_ScreenPanel ) MUI_DeleteCustomClass(CL_ScreenPanel );
  2668.     if (CL_ScreenList  ) MUI_DeleteCustomClass(CL_ScreenList  );
  2669.     if (CL_DispIDinfo  ) MUI_DeleteCustomClass(CL_DispIDinfo  );
  2670.     if (CL_DispIDlist  ) MUI_DeleteCustomClass(CL_DispIDlist  );
  2671.     if (CL_EditPanel   ) MUI_DeleteCustomClass(CL_EditPanel   );
  2672.     if (CL_EditWindow  ) MUI_DeleteCustomClass(CL_EditWindow  );
  2673.     if (CL_SysPenField ) MUI_DeleteCustomClass(CL_SysPenField );
  2674. }
  2675.  
  2676. BOOL InitClasses(VOID)
  2677. {
  2678.     CL_SysPenField  = MUI_CreateCustomClass(NULL,MUIC_Pendisplay,NULL,sizeof(struct SysPenField_Data ),SysPenField_Dispatcher );
  2679.     CL_EditWindow   = MUI_CreateCustomClass(NULL,MUIC_Window    ,NULL,sizeof(struct EditWindow_Data  ),EditWindow_Dispatcher  );
  2680.     CL_EditPanel    = MUI_CreateCustomClass(NULL,MUIC_Group     ,NULL,sizeof(struct EditPanel_Data   ),EditPanel_Dispatcher   );
  2681.     CL_DispIDlist   = MUI_CreateCustomClass(NULL,MUIC_List      ,NULL,sizeof(struct DispIDlist_Data  ),DispIDlist_Dispatcher  );
  2682.     CL_DispIDinfo   = MUI_CreateCustomClass(NULL,MUIC_Group     ,NULL,sizeof(struct DispIDinfo_Data  ),DispIDinfo_Dispatcher  );
  2683.     CL_ScreenList   = MUI_CreateCustomClass(NULL,MUIC_List      ,NULL,sizeof(struct ScreenList_Data  ),ScreenList_Dispatcher  );
  2684.     CL_ScreenPanel  = MUI_CreateCustomClass(NULL,MUIC_Group     ,NULL,sizeof(struct ScreenPanel_Data ),ScreenPanel_Dispatcher );
  2685.     CL_MainWindow   = MUI_CreateCustomClass(NULL,MUIC_Window    ,NULL,sizeof(struct MainWindow_Data  ),MainWindow_Dispatcher  );
  2686.  
  2687.     if (CL_SysPenField && CL_EditWindow && CL_EditPanel && CL_DispIDlist && CL_DispIDinfo && CL_ScreenList && CL_ScreenPanel && CL_MainWindow)
  2688.         return(TRUE);
  2689.  
  2690.     ExitClasses();
  2691.     return(FALSE);
  2692. }
  2693.  
  2694.  
  2695. const char CLITemplate[] = "NAME,OPEN/S,CLOSE/S";
  2696.  
  2697. const char CLIHelp[] = "\
  2698. \n\
  2699. Usage: PSI <name> OPEN/CLOSE\n\
  2700. <name>: name of (preconfigured) public screen\n\
  2701.  OPEN : open this public screen\n\
  2702.  CLOSE: close this public screen\n\
  2703. ";
  2704.  
  2705. LONG HandleArgs(Object *mainwin)
  2706. {
  2707.     struct MUI_PubScreenDesc *desc;
  2708.     struct RDArgs *rda,*rdas;
  2709.     LONG msg = 0;
  2710.     struct CLIArgs
  2711.     {
  2712.         char *Name;
  2713.         LONG Open;
  2714.         LONG Close;
  2715.     } argarray = { 0,0,0 };
  2716.  
  2717.     if (rdas = AllocDosObject(DOS_RDARGS,NULL))
  2718.     {
  2719.         rdas->RDA_ExtHelp = (char *)CLIHelp;
  2720.  
  2721.         if (rda = ReadArgs((char *)CLITemplate,(LONG *)&argarray,rdas))
  2722.         {
  2723.             if (argarray.Name)
  2724.             {
  2725.                 DoMethod(mainwin,MUIM_ScreenList_Find,argarray.Name,&desc);
  2726.  
  2727.                 if (argarray.Open)
  2728.                 {
  2729.                     if (!desc)
  2730.                         msg = MSG_CLI_SCREENNOTFOUND;
  2731.                     else if (MUIS_OpenPubScreen(desc))
  2732.                         msg = MSG_CLI_SCREENOPENED;
  2733.                     else
  2734.                         msg = MSG_CLI_SCREENOPENFAILED;
  2735.                 }
  2736.                 else if (argarray.Close)
  2737.                 {
  2738.                     if (!desc)
  2739.                         msg = MSG_CLI_SCREENNOTFOUND;
  2740.                     else if (MUIS_ClosePubScreen(desc->Name))
  2741.                         msg = MSG_CLI_SCREENCLOSED;
  2742.                     else
  2743.                         msg = MSG_CLI_SCREENCLOSEFAILED;
  2744.                 }
  2745.             }
  2746.             else
  2747.             {
  2748.                 if (argarray.Open || argarray.Close)
  2749.                     msg = MSG_CLI_SYNTAXERROR;
  2750.             }
  2751.             FreeArgs(rda);
  2752.         }
  2753.         FreeDosObject(DOS_RDARGS,rdas);
  2754.     }
  2755.     else
  2756.         msg = MSG_CLI_OUTOFMEMORY;
  2757.  
  2758.     return(msg);
  2759. }
  2760.  
  2761.  
  2762.  
  2763. /****************************************************************************/
  2764. /* Main Program                                                             */
  2765. /****************************************************************************/
  2766.  
  2767. /*int main(int argc,char *argv[])*/
  2768. void __stdargs __main(char *comline)
  2769. {
  2770.     extern struct WBStartup *_WBenchMsg;
  2771.     struct MUIS_InfoClient sic;
  2772.     ULONG sigs=0;
  2773.     Object *app;
  2774.     Object *win;
  2775.     int res;
  2776.     int msg;
  2777.  
  2778.     InitLocale();
  2779.  
  2780.     if (InitLibs())
  2781.     {
  2782.         if (InitClasses())
  2783.         {
  2784.             app = ApplicationObject,
  2785.                 MUIA_Application_Title      , "PSI",
  2786.                 MUIA_Application_Version    , "$VER: PSI 17.6 (18.08.96)",
  2787.                 MUIA_Application_Copyright  , "©1995, Stefan Stuntz",
  2788.                 MUIA_Application_Author     , "Stefan Stuntz",
  2789.                 MUIA_Application_Description, "Public Screen Inspector",
  2790.                 MUIA_Application_Base       , "PSI",
  2791.                 MUIA_Application_Window     , win = NewObject(CL_MainWindow->mcc_Class,NULL,TAG_DONE),
  2792.                 End;
  2793.  
  2794.             if (app)
  2795.             {
  2796.                 if (/*argc==0*/ _WBenchMsg)
  2797.                     msg = 0;
  2798.                 else
  2799.                     msg = HandleArgs(win);
  2800.  
  2801.                 if (!msg)
  2802.                 {
  2803.                     set(win,MUIA_Window_Open,TRUE);
  2804.  
  2805.                     /* special magic to keep track about public screen open/close status */
  2806.                     sic.task   = FindTask(NULL);
  2807.                     sic.sigbit = SIGBREAKF_CTRL_E;
  2808.                     MUIS_AddInfoClient(&sic);
  2809.  
  2810.                     while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  2811.                     {
  2812.                         if (sigs)
  2813.                         {
  2814.                             sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);
  2815.  
  2816.                             /* quit when receiving break from console */
  2817.                             if (sigs & SIGBREAKF_CTRL_C)
  2818.                                 break;
  2819.  
  2820.                             /* update listview whenever a screen was opened/closed */
  2821.                             if (sigs & SIGBREAKF_CTRL_E)
  2822.                                 DoMethod(win,MUIM_ScreenPanel_Update);
  2823.  
  2824.                             /* deiconify & activate on ctrl-f just like the other prefs programs */
  2825.                             if (sigs & SIGBREAKF_CTRL_F)
  2826.                             {
  2827.                                 set(app,MUIA_Application_Iconified,FALSE);
  2828.                                 set(win,MUIA_Window_Open,TRUE);
  2829.                             }
  2830.                         }
  2831.                     }
  2832.  
  2833.                     MUIS_RemInfoClient(&sic);
  2834.  
  2835.                     DoMethod(win,MUIM_ScreenPanel_CloseWindows);
  2836.                     set(win,MUIA_Window_Open,FALSE);
  2837.                 }
  2838.                 MUI_DisposeObject(app);
  2839.             }
  2840.             else msg = MSG_CLI_NOAPPLICATION;
  2841.             ExitClasses();
  2842.         }
  2843.         else msg = MSG_CLI_OUTOFMEMORY;
  2844.         ExitLibs();
  2845.     }
  2846.     else msg = MSG_CLI_NOMUIMASTER;
  2847.  
  2848.     if (msg)
  2849.     {
  2850.         char *str = GetStr(msg);
  2851.         char *c = strchr(str,'(');
  2852.         Write(Output(),str,strlen(str));
  2853.         res = c ? atol(c+1) : RETURN_OK;
  2854.     }
  2855.     else
  2856.         res = RETURN_OK;
  2857.  
  2858.     ExitLocale();
  2859.     /*return(res);*/
  2860.     exit(res);
  2861. }
  2862.